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
3
votes
1 answer

StringTemplate does not find getter

I am using ST-4.0.7.jar and my template looks like this: backtrack_result(btresult) ::=<< $btresult.pattern.description$ $btresult.file.file.path$
er4z0r
  • 4,711
  • 8
  • 42
  • 62
3
votes
1 answer

StringTemplate 4 and Python

I've just found out StringTemplate and wanted to test it in python. Does v4 work in Python (2.7/3)? Wiki is empty and I can't find any info about python port for v4 version. v3 is the only working version (in ofc Python)?
Simon
  • 2,329
  • 4
  • 30
  • 49
2
votes
1 answer

How are error messages in StringTemplate to be interpreted?

I got this error message while using StringTemplate: line 94:26: unexpected char: ')' And after about 15 minutes of randomly adding and removing blank lines in my template, and observing how the number in that message changed, I finally isolated…
Sebastien Diot
  • 7,183
  • 6
  • 43
  • 85
2
votes
2 answers

Comma between optional statements

I am trying to generate code with stringtemplate4, and I have a line like this: "\"A\":\"\", \"B\":\"\", \"C\":\"\"" so A, B and C are optional parameters that if they are not set, I don't want the…
Shahab78
  • 277
  • 1
  • 11
2
votes
1 answer

Stringtemplate 4 (st4) - Render if string is not empty

I need an st4 expression to render an element if a string is not empty: ... does not work - it seems to only work for arrays. I've tried if(theString.length > 0) and all kinds of stuff, but it looks like it this only works for…
mikeb
  • 10,578
  • 7
  • 62
  • 120
2
votes
0 answers

StringTemplate use object property in format of renderer call

I'm referencing c# resource strings from my template (which uses $ as delimiters). I'm doing so by passing in as one of the arguments to the template the object "strings", which is a c# ResourceManager. The formatString is expected to be the name…
AliceW
  • 41
  • 2
2
votes
0 answers

StringTemplate is there a way to convert an empty string to null?

I have a situation where I need to utilise the wrapping and anchor functionality on a list of object attributes that have formatting. I can create a list in string template and then strip out null values, if they are just direct property access.…
2
votes
2 answers

Read templates from a file StringTemplate

I'm using the template engine StringTemplate for some templates (obviously). What I want is to be able to store the templates I have in seperate files, ofcourse I can do that with simple .txt files and reading them into a String, looks a bit like…
Liam de Haas
  • 1,258
  • 3
  • 18
  • 39
2
votes
2 answers

Custom format functions for StringTemplate4

I would like to know how to create a custom format function for string template. Let say I have the following code: render(attributes) :: << $atributes: {
$customformat(atribute.name)$
Julio
  • 849
  • 2
  • 10
  • 17
2
votes
1 answer

Apache Camel / String template component / Template Groups

In Apache Camel, is it possible to use template groups (c.f. https://theantlrguy.atlassian.net/wiki/display/ST4/Group+file+syntax) using the string-template component ? I would like to load a template group file to be able to used the named…
b_habegger
  • 309
  • 2
  • 13
2
votes
1 answer

Combining Antlr 3.5.2 with StringTemplate 4 for code generation

Current project I'm working on is limited to using antlr 3.5.2, but I would like to use the featureset of StringTemplate 4 for our code generation. Can antlr 3.5.2 generate a java treewalker that uses StringTemplate 4? (e.g. a tree grammer with…
Bas
  • 834
  • 6
  • 15
2
votes
1 answer

custom string delimiters stringtemplate-4

I am trying to use stringtemplate-4 engine in android. But I need starting delimiter, " {{ " while ending delimiter should be, " }} " Here, I think only char delimiters are allowed. So how to use string delimiters? Thnx in advance.
userx
  • 806
  • 1
  • 11
  • 23
2
votes
2 answers

Unable to catch STException in StringTemplate 4

I am unable to catch the STException thrown by the STGroupFile. This is a problem. I need to abort if the template is bad. To reproduce this problem, I have this incorrect template file called tmp.stg: temp1(param1)::=<< %if(param1)% …
user1241663
  • 191
  • 1
  • 11
2
votes
1 answer

Implement custom functions in stringtemplate v4

In StringTemplate v3 we had a custom Java HashMap implementation that would call a function on the key provided and return the function result instead of doing an actual hashmap lookup. We would add an instance of this HashMap as an attribute to…
2
votes
1 answer

Appaling RazorEngine 3.3 performance, compared to StringTemplate4

Is there any reason or anything I am doing wrong, why RazorEngine is so slow just to parse 100 different templates? I was looking into StringTemplate, and performed two tests to compare, as per below. [Test] public void…
Karl Cassar
  • 6,043
  • 10
  • 47
  • 84
1 2
3
9 10