You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@velocity.apache.org by "Claude Brisson (Jira)" <ji...@apache.org> on 2021/02/27 08:37:00 UTC
[jira] [Commented] (VELOCITY-927) Parsing problem with space before
closing curly bracket
[ https://issues.apache.org/jira/browse/VELOCITY-927?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17292057#comment-17292057 ]
Claude Brisson commented on VELOCITY-927:
-----------------------------------------
Fixed in master.
> Parsing problem with space before closing curly bracket
> -------------------------------------------------------
>
> Key: VELOCITY-927
> URL: https://issues.apache.org/jira/browse/VELOCITY-927
> Project: Velocity
> Issue Type: Bug
> Components: Engine
> Affects Versions: 2.2
> Reporter: Al Bundy
> Assignee: Claude Brisson
> Priority: Major
>
> After updateing from a slightly outdated velocity 1.x to 2.x wo have some issues with our existing templates.
> Some of them are already fixed in 2.2 but at least for now we still have one issue.
> This template
> {code:java}
> #set ( $nameMap10 =
> {
> }){code}
> results in
> {code:java}
> org.apache.velocity.runtime.parser.TemplateParseException: Encountered "}" at test[line 3, column 5]
> Was expecting one of:
> "[" ...
> "{" ...
> <WHITESPACE> ...
> <NEWLINE> ...
> <STRING_LITERAL> ...
> "true" ...
> "false" ...
> <INTEGER_LITERAL> ...
> <FLOATING_POINT_LITERAL> ...
> <IDENTIFIER> ...
> <OLD_IDENTIFIER> ...
> "{" ...
> "[" ...
> {code}
> it seems that the whitespaces and newlines in this example matter.
> Modifying the tempalte to
> {code:java}
> #set ( $nameMap10 =
> {})
> {code}
> seems to workaround this issue but it would be nice if this would be fixed in Velocity.
>
> Here is a small test-case:
> {code:java}
> @Test
> public void testEmptyMap()
> throws Exception
> {
> final String _empty_map = new StringBuilder()
> .append(" #set ( $nameMap10 =\n")
> .append(" {\n")
> .append(" })\n")
> .toString();
> final Template _template = new Template();
> _template.setRuntimeServices(RuntimeSingleton.getRuntimeServices());
> _template.setEncoding(ModuleManager.getInstance().getDefaultEncoding());
> _template.setName("test");
> _template.setData(RuntimeSingleton.getRuntimeServices().parse(new StringReader(_empty_map.toString()), _template));
> _template.initDocument();
> final VelocityContext _context = new VelocityContext();
> _template.merge(_context, new StringWriter());
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@velocity.apache.org
For additional commands, e-mail: dev-help@velocity.apache.org