stringtemplate

What are the main differences between StringTemplate and FreeMarker?

谁说我不能喝 提交于 2019-12-02 23:35:30
The net seems to be full of comparisons between Velocity and FreeMarker, and they seem to be reasonably equivalent. But there seems to be almost no comparisons between StringTemplate and FreeMarker! So, what are the main differences between StringTemplate and FreeMarker? My usage for them would be to generate HTML pages only. Out of the two, I would've expected FreeMarker to be the more suitable and more capable, as that seems to the more common one - but through a quick glance it seems that StringTemplate actually has more suitable features! It would be great if someone who has used both

Filter out empty strings in ST4

蓝咒 提交于 2019-12-02 12:19:38
问题 Consider the following example: <["foo", "", "bar"]; separator=","> This gives the result: foo,,bar But I need: foo,bar Is there any way to filter out empty string values before formating with separator in ST4? (In real code the values come from another template, which has <if> condition and returns empty result for undesired data from model, and I don't whant to move the condition out of that template to keep templates incapsulated/isolated.) 回答1: I've found the workaround with two auxilary

Filter out empty strings in ST4

╄→гoц情女王★ 提交于 2019-12-02 04:37:46
Consider the following example: <["foo", "", "bar"]; separator=","> This gives the result: foo,,bar But I need: foo,bar Is there any way to filter out empty string values before formating with separator in ST4? (In real code the values come from another template, which has <if> condition and returns empty result for undesired data from model, and I don't whant to move the condition out of that template to keep templates incapsulated/isolated.) I've found the workaround with two auxilary things. But it is so creepy... DropEmpty ::= ["": [], default: key] Separated(l, s, w=false) ::= "<if

StringTemplate remove < > as delimiters

[亡魂溺海] 提交于 2019-12-01 17:37:17
I am trying to use StringTemplate in a java web app to generate html emails. When trying to enter line breaks, I use \<br\> This does not seem to be working. \<b\> is not working as well. Is there a way to turn off < and > as delimiters so I can test if this is the issue? All over the StringTemplate documentation it says to use $...$ as your delimiters but doesn't say how to not use <...> When creating a group you can set the delimiters by using STGroup group = new STGroupDir("emails", '$','$'); Where '$' and '$' are your delimiters. Although Lumpy definitely answered the question correctly,

StringTemplate remove < > as delimiters

余生颓废 提交于 2019-12-01 16:24:10
问题 I am trying to use StringTemplate in a java web app to generate html emails. When trying to enter line breaks, I use \<br\> This does not seem to be working. \<b\> is not working as well. Is there a way to turn off < and > as delimiters so I can test if this is the issue? All over the StringTemplate documentation it says to use $...$ as your delimiters but doesn't say how to not use <...> 回答1: When creating a group you can set the delimiters by using STGroup group = new STGroupDir("emails", '

Where to get Python ANTLR package to use StringTemplate?

随声附和 提交于 2019-12-01 06:43:38
问题 I'd like to do some code generation, and StringTemplate looks like a pretty good tool for the job. I easy_installed stringtemplate3 from PyPi, but when I try to import it I get: ImportError: No module named antlr I am confused by this because I thought that ANTLR depended on StringTemplate (as the website says), not the other way around. In any case, I cannot find the correct package to fix this. Installing antlr_python_runtime did not help. Any hints? 回答1: You need to have the python-antlr

What is the best way to ensure HTML entities are escaped in StringTemplate

不羁岁月 提交于 2019-12-01 01:29:31
Assuming the following string template, is being given a list of Java Bean objects: <ul>$people:{p|<li>$p.name$ $p.email</li>}$</ul> ie the list of people might contain Person objects which you may or may not have the ability to enhance/extend: class Person { .... public getName() { ... } public getEmail() { ... } } The getName() and getEmail() methods don't return sanitised (escaped html entities). How do you get around this? You may use a custom renderer, for example: public static class HtmlEscapeStringRenderer implements AttributeRenderer { public String toString(Object o, String s, Locale

JQuery's $ is in conflict with that of StringTemplate.Net in ASP.Net MVC

亡梦爱人 提交于 2019-11-27 03:46:56
I am exploring ASP.NET MVC and I wanted to add jQuery to make the site interactive. I used StringTemplate, ported to .Net, as my template engine to generate html and to send JSON. However, when I view the page, I could not see it. After debugging, I've realized that the $ is used by the StringTemplate to access property, etc and jQuery uses it too to manipulate the DOM. Gee, I've looked on other template engines and most of them uses the dollar sign :(. Any alternative template engine for ASP.Net MVC? I wanted to retain jQuery because MSFT announced that it will used in the Visual Studio (2008