Questions tagged [stringtemplate-4]

StringTemplate is a java template engine

StringTemplate is a java template engine (with ports for C#, Python) for generating source code, web pages, emails, or any other formatted text output. StringTemplate is particularly good at code generators, multiple site skins, and internationalization / localization. StringTemplate also generates this website and powers ANTLR.

137 questions
17
votes
2 answers

how do I iterate though a java list in stringtemplate?

I want to iterate through a hibernate query results inside stringtemplate. I've been looking for examples but I can't find anything. can you please help? thanks
mrjayviper
  • 2,258
  • 11
  • 46
  • 82
8
votes
2 answers

How can I iterate over the keys and values of a String Template 4 Map?

In StringTemplate 4, the default behavior for iteration is to iterate over the keys instead of the values, which was the behavior in version 3. I can not find the syntax for how to iterate over the keys and values at the same time for version 4. Can…
user177800
7
votes
3 answers

StringTemplate remove < > as delimiters

I am trying to use StringTemplate in a java web app to generate html emails. When trying to enter line breaks, I use \ This does not seem to be working. \ is not working as well. Is there a way to turn off < and > as delimiters so I can…
Lumpy
  • 3,632
  • 4
  • 34
  • 58
6
votes
0 answers

StringTemplate getInstanceOf returns null

Good Day! I started using StringTemplate and I encountered a pretty annoying problem. I have a simple Template "T.st" T(name, email, passwort) ::= << ... >> It is saved in a directory "templates" which is part of my source folder…
tagtraeumer
  • 1,451
  • 11
  • 19
6
votes
1 answer

Translation of PL/SQL code to Java using Antlr 4 and stringtemplate 4

I am trying to construct a translator that could convert PL/SQL code to Java using Antlr 4 and StringTemplate 4. I have the grammar of PL/SQl and have already build a parser for PL/SQL but i have no idea how to approach the problem further. I found…
ayush narula
  • 11,275
  • 2
  • 15
  • 18
6
votes
2 answers

StringTemplate list of attributes defined for a given template

I am getting started with StringTemplate 4 and I am trying to create a template from a simple string stored in a database. I use something like this: STGroup group = new STGroupString(null, someTemplateString, '$', '$'); ST st =…
Giovanni Botta
  • 9,626
  • 5
  • 51
  • 94
5
votes
1 answer

Where can I download full example java project that uses stringtemplate?

http://www.antlr.org/wiki/display/ST4/StringTemplate+4+Wiki+Home, http://www.stringtemplate.org/ I looked on the wiki and I may be missing the forest through all the trees, but I need to see a fully working java project not a bunch of snips. …
JStark
  • 2,788
  • 2
  • 29
  • 37
5
votes
1 answer

Stringtemplate - How to set date format to locale format

I'm processing Excel files with ExcelExplorer based on Stringtemplate4 (ST). The files contain several columns with dates. By default, the dates are rendered following the "MM/dd/yy" date format. Is there a way to render the dates as…
4
votes
1 answer

StringTemplate4 and anonymous templates

I have a problem with the recently released beta version of Stringtemplate 4. In StringTemplate 3, I used to have templates like () { return null; }}> i.e. anonymous templates containing a literal closing brace ("}"),…
pmf
  • 7,619
  • 4
  • 47
  • 77
4
votes
2 answers

Convert First Letter to Capital using String Template

I am using String template file to generate java files. For that i am using ANTLR. Code for One of the string template file is shown below: package framework; public abstract class Listener$GUIdriver.name$ { $GUIdriver.commands:{ command | …
user5182542
4
votes
0 answers

Line wrapping with white space padding using stringtemplate

How can I pad a sentence with white space so that it is printed in a 'block'. I want to print a receipt. for a given item I want to print the quantity, item name, and price. 12 x Example short name £2.00 1 x This is an example of a long…
4
votes
0 answers

NoIndentWriter not respecting whitespace in template

I am trying to use the NoIndentWriter class to get around a problem I am facing related to the inserting of whitespace in multiline Strings. However, it appears that NoIndentWriter does a lot more than just not auto-indenting. In particular it trims…
Marcus Junius Brutus
  • 26,087
  • 41
  • 189
  • 331
4
votes
2 answers

curly braclet in a StringTemplate

The following StringTemplate gives me an "invalid character '}'" exception because of the closing curly brace after return null;: $StatementList:{statement | public T $statement$(X x) { return null; } }$ I want to have an output like: public T…
Klaus Schulz
  • 527
  • 1
  • 5
  • 20
4
votes
2 answers

How to escape HTML by default in StringTemplate?

It is very good practice in HTML template engines to HTML-escape by default placeholder text to help prevent XSS (cross-site scripting) attacks. Is it possible to achieve this behavior in StringTemplate? I have tried to register custom…
dened
  • 4,253
  • 18
  • 34
4
votes
1 answer

How to write to an OutputStream directly using Stringtemplate 4.x?

I don't want to call .render() and build extremely large Strings from some of my templates. In previous versions you could write to an OutputStream directly instead of having to render the entire template to a String and then write that out. I tried…
user177800
1
2 3
9 10