Al Bundy created VELOCITY-927:
---------------------------------
Summary: Compatibility to Velocity 1.x
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
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: [email protected]
For additional commands, e-mail: [email protected]