[ 
https://issues.apache.org/jira/browse/VELOCITY-912?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Mark Estrada updated VELOCITY-912:
----------------------------------
    Description: 
I have this template:
{code:java}
hello-world.properties.vm 
 ---------------------------------------------------------- 
 Slash: ${sample-slash}
 Slash in a Map: ${map.sample-slash}{code}
----------------------------------------------------------
 And I have this sample test case:

 
{code:java}
public class ApacheVelocityTest {
private final String RESOURCES_DIR = "src/test/resources";

@Test
public void testVelocity() {
Path templatePath = Paths.get(RESOURCES_DIR, "templates", 
"hello-world.properties.vm");


VelocityEngine ve = new VelocityEngine();
ve.setProperty(Velocity.PARSER_HYPHEN_ALLOWED, true);

ve.init();
Template t = ve.getTemplate(templatePath.toString());

VelocityContext context = new VelocityContext();

context.put("sample-slash", "SLASH");

Map<String, String> sampleData = createData();
context.put("map", sampleData);

StringWriter writer = new StringWriter();
t.merge(context, writer);

System.out.println(writer.toString());
}

public Map<String, String> createData() {
Map<String, String> mapData = new HashMap<String, String>();

mapData.put("sample-slash", "USER1");

return mapData;

}
}
{code}
 

Now, the first "sample-slash" is rendered correctly but the one that is in the 
config map is not..it is throwing out an error like this:

---------------------------------------------------------------------
{code:java}
org.apache.velocity.exception.ParseErrorException: Encountered "-slash}" at 
src\test\resources\templates\hello-world.properties.vm[line 5, column 22]
 Was expecting one of:
 "[" ...
 "|" ...
 "}" ...
 "}" ...
at org.apache.velocity.Template.process(Template.java:154)
{code}
 

The parser exception is being thrown by the object that is embedded into the 
java map.

Do I have any workaround for this developers? Any pointers are greatly 
appreciated.

  was:
I have this template:
{code:java}
hello-world.properties.vm 
 ---------------------------------------------------------- 
 Slash: ${sample-slash}
 Slash in a Map: ${map.sample-slash}{code}
----------------------------------------------------------
 And I have this sample test case:

 
{code:java}
public class ApacheVelocityTest {
 private final String RESOURCES_DIR = "src/test/resources";
@Test
 public void testVelocity()
{ Path templatePath = Paths.get(RESOURCES_DIR, "templates", 
"hello-world.properties.vm"); VelocityEngine ve = new VelocityEngine(); 
ve.setProperty(Velocity.PARSER_HYPHEN_ALLOWED, true); ve.init(); Template t = 
ve.getTemplate(templatePath.toString()); VelocityContext context = new 
VelocityContext(); context.put("sample-slash", "SLASH"); Map<String, String> 
sampleData = createData(); context.put("map", sampleData); StringWriter writer 
= new StringWriter(); t.merge(context, writer); 
System.out.println(writer.toString()); }
public Map<String, String> createData()
{ Map<String, String> mapData = new HashMap<String, String>(); 
mapData.put("sample-slash", "USER1"); return mapData; }
}
{code}
 

Now, the first "sample-slash" is rendered correctly but the one that is in the 
config map is not..it is throwing out an error like this:

---------------------------------------------------------------------
{code:java}
org.apache.velocity.exception.ParseErrorException: Encountered "-slash}" at 
src\test\resources\templates\hello-world.properties.vm[line 5, column 22]
 Was expecting one of:
 "[" ...
 "|" ...
 "}" ...
 "}" ...
at org.apache.velocity.Template.process(Template.java:154)
{code}
 

The parser exception is being thrown by the object that is embedded into the 
java map.

Do I have any workaround for this developers? Any pointers are greatly 
appreciated.


> Hyphen Handling in Identifiers that are inside java collection
> --------------------------------------------------------------
>
>                 Key: VELOCITY-912
>                 URL: https://issues.apache.org/jira/browse/VELOCITY-912
>             Project: Velocity
>          Issue Type: Bug
>          Components: Engine
>    Affects Versions: 2.1
>            Reporter: Mark Estrada
>            Priority: Major
>
> I have this template:
> {code:java}
> hello-world.properties.vm 
>  ---------------------------------------------------------- 
>  Slash: ${sample-slash}
>  Slash in a Map: ${map.sample-slash}{code}
> ----------------------------------------------------------
>  And I have this sample test case:
>  
> {code:java}
> public class ApacheVelocityTest {
> private final String RESOURCES_DIR = "src/test/resources";
> @Test
> public void testVelocity() {
> Path templatePath = Paths.get(RESOURCES_DIR, "templates", 
> "hello-world.properties.vm");
> VelocityEngine ve = new VelocityEngine();
> ve.setProperty(Velocity.PARSER_HYPHEN_ALLOWED, true);
> ve.init();
> Template t = ve.getTemplate(templatePath.toString());
> VelocityContext context = new VelocityContext();
> context.put("sample-slash", "SLASH");
> Map<String, String> sampleData = createData();
> context.put("map", sampleData);
> StringWriter writer = new StringWriter();
> t.merge(context, writer);
> System.out.println(writer.toString());
> }
> public Map<String, String> createData() {
> Map<String, String> mapData = new HashMap<String, String>();
> mapData.put("sample-slash", "USER1");
> return mapData;
> }
> }
> {code}
>  
> Now, the first "sample-slash" is rendered correctly but the one that is in 
> the config map is not..it is throwing out an error like this:
> ---------------------------------------------------------------------
> {code:java}
> org.apache.velocity.exception.ParseErrorException: Encountered "-slash}" at 
> src\test\resources\templates\hello-world.properties.vm[line 5, column 22]
>  Was expecting one of:
>  "[" ...
>  "|" ...
>  "}" ...
>  "}" ...
> at org.apache.velocity.Template.process(Template.java:154)
> {code}
>  
> The parser exception is being thrown by the object that is embedded into the 
> java map.
> Do I have any workaround for this developers? Any pointers are greatly 
> appreciated.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@velocity.apache.org
For additional commands, e-mail: dev-h...@velocity.apache.org

Reply via email to