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
4
votes
3 answers

How to escape a StringTemplate template?

I am trying to process the template (see below) and I'm getting all sorts of messages in the eclipse console. I've searched the net but can't really find what I'm looking for. I recall seeing something on this topic here but I didn't bookmark it at…
mrjayviper
  • 2,258
  • 11
  • 46
  • 82
4
votes
2 answers

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

Assuming the following string template, is being given a list of Java Bean objects:
    $people:{p|
  • $p.name$ $p.email
  • }$
ie the list of people might contain Person objects which you may or may not have the ability to…
Jay
  • 19,649
  • 38
  • 121
  • 184
4
votes
2 answers

How to get StringTemplate V4 to ignore < as delimiter?

I'm using StringTemplate V4 to generate some HTML code in my project. I need to have HTML formatting in my templates, so using the default delimiters < and > would be very awkward. So, I'm creating a group passing the delimiter as argument (as…
Elias Dorneles
  • 22,556
  • 11
  • 85
  • 107
4
votes
1 answer

Calling Java function with arguments from StringTemplate?

StringTemplate allows programmers to fetch data through getters(a function with no arguments). I would like to know that Is it possible to call Java function with arguments from String Template?
user-517752
  • 1,188
  • 5
  • 21
  • 54
3
votes
1 answer

Stringtemplate-4: using '@' as a custom delimiter

When using StringTemplate 4.0.2 the following object construction: ST st = new ST("@myToken@", '@', '@'); produces the exception: 1:8: '@' came as a complete surprise to me Exception in thread "main" org.stringtemplate.v4.compiler.STException …
andrew b
  • 205
  • 2
  • 6
3
votes
1 answer

jdbi version 3, stringtemplate when to escape <, > characters?

I am using jdbi3 with StringTemplate 4 templating engine, I have this test query: @SqlQuery("select * from test " + "where field1 = 5" + " or field2 \\<= :value1" + " or field2 >=…
res1
  • 3,482
  • 5
  • 29
  • 50
3
votes
0 answers

how do I iterate though a jsonarray in stringtemplate v4 in JAVA?

I have JSON object which holds the data and I want to generate the new JSON object with the help of String template 4 iterating over the input JSON. Suppose I have an input JSON object as follow Input json :- { "list": [ { "ID": "1", …
Navnath
  • 133
  • 1
  • 9
3
votes
1 answer

Dictionary with dynamic entries in StringTemplate

I'm using StringTemplate 4.0.8 with Java. In the StringTemplate-4 documentation, it says that Dictionary strings can also be templates that can refer to attributes that will become visible via dynamic scoping of attributes once the dictionary…
Colophonius
  • 43
  • 1
  • 1
  • 6
3
votes
1 answer

StringTemplate indentation adds whitespace inside String

This is obviously a SSCCE. I have the following template file: xml(value)::=<< ^value^ >> ... with the following code: private static final String VALUE="alpha\nbeta"; public static void main(String args[]) throws…
Marcus Junius Brutus
  • 26,087
  • 41
  • 189
  • 331
3
votes
1 answer

How to retrieve error message in StringTemplate?

How can I retrieve a compile time error message from StringTemplate as a String? This code for instance: STGroup stg = new STGroup('<', '>'); CompiledST compiledTemplate = stg.defineTemplate("receipt", ""); if (compiledTemplate…
wvdz
  • 16,251
  • 4
  • 53
  • 90
3
votes
1 answer

How to get Attributes in StringTemplate v4

I have following code String templateString = "Some Text $attribute1$ more text $attribute2$ more text"; ST stringTemplate = new ST(templateString ,'$','$');` How can I iterate over all attributes i.e. attribute1, attribute2 etc? I want to get all…
user3751014
  • 41
  • 1
  • 4
3
votes
2 answers

In ST4/C#, can you register a new renderer without a TemplateGroup?

The only place the RegisterRenderer method appears is on TemplateGroup. But I just have a single template, supplied via a string, not multiple templates on the file system. Alternately, how can I use a TemplateGroup but supply the template(s) via a…
Deane
  • 8,269
  • 12
  • 58
  • 108
3
votes
1 answer

String Template 4 Problems with STGroupDir

We have been using string template in java for a while and have just upgraded to String Template 4.0.7. In string template 3.2 (The version we were previously using), I had a string template file called stringtemplate.st in src/main/resources, and…
Ben Green
  • 3,953
  • 3
  • 29
  • 49
3
votes
1 answer

StringTemplate check if array is empty in java

How to check using the StringTemplate if the array is not empty? The example below doesn't work: 0)>
    }>
Other (not working) Exaple: String content = "list:…
czerasz
  • 13,682
  • 9
  • 53
  • 63
3
votes
3 answers

'{' came as a complete surprise to me

I want to use org.stringtemplate.v4.* as template engine for rendering html pages. However I cant find how to escape open brackets in my file. Templator thinks that it is some expression, while it is just javascript code. I tried \{ but this not…
msangel
  • 9,895
  • 3
  • 50
  • 69
1
2
3
9 10