tomj74 / chunk-templates

Chunk Templates, a template engine for Java
http://www.x5software.com/chunk/
MIT License
77 stars 10 forks source link

Can't use CDATA #16

Closed dmitrikudrenko closed 8 years ago

dmitrikudrenko commented 8 years ago

I have a troubles when I set expression like this Cucumber<br>in xml like that <p>{$item.name}</p>. In that case I receive invalid xml - <p>Cucumber<br></p>. I tryed change xml-pattern to <p><![CDATA[{$item.name}]]><p>. But in that case I receive weird result: <p><!--[CDATA[Cucumber<br>]]--></p> Why do you comment CDATA? Can you offer me some workaround?

tomj74 commented 8 years ago

As a quick workaround, you should be able to use &lt; and &gt; in place of the angle brackets and they will be rendered properly. CDATA support is likely to be pretty hacky/brittle but I'll look into it.

dmitrikudrenko commented 8 years ago

Well, I set objects to chunk. I wouldn't like to change objects

tomj74 commented 8 years ago

Oh, I misunderstood the question. I think what you really want is to escape the value properly? There are template filters that exist for exactly this purpose:

<p>{$item.name|xmlescape}</p>

This can be abbreviated to just:

<p>{$item.name|xml}</p>
tomj74 commented 8 years ago

As far as the comment tags go, I am unable to reproduce the behavior you are seeing. Can you attach a simple case of template and java code that produces the mysterious commenting?

tomj74 commented 8 years ago

closing for now, will reopen if reproducible case is submitted.