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
2
votes
2 answers

error running JSON2XML_ST

i try to run JSON2XML_ST ike this: bab@maz:~/tpantlr2-code/code/listeners$ antlr4 JSON.g4 bab@maz:~/tpantlr2-code/code/listeners$ javac JSON2XML_ST.java bab@maz:~/tpantlr2-code/code/listeners$ java JSON2XML_ST t.json but a i got : (json (object…
2
votes
1 answer

StringTemplate don't replace non-matched patterns

suppose I have a template "{man} likes to do {do}" I create the engine ST engine = new ST(template, '{', '}'); The result with do set to sports and no man in the model is: "likes to do sports" but I'd prefer it to stay unresolved, that…
Parobay
  • 2,549
  • 3
  • 24
  • 36
2
votes
1 answer

Is it possible to combine group files and group directories?

I am using StringTemplate to generate HTML and I would like to be able to combine STGroupFile and STGroupDir such that I have a directory of group files. This way I can include multiple templates in one file but also combine templates from multiple…
Pete
  • 41
  • 4
2
votes
3 answers

StringTemplate : how to import from a jar?

I have a case where I am loading a string template group from a file contained in a jar. This works fine using the following mechanism: final String urlName = new StringBuilder() …
phreed
  • 1,759
  • 1
  • 15
  • 30
2
votes
1 answer

ANTLR + StringTemplate -Create a JavaLike language and translate it into PLSql, C and C++

Hello I am trying to implement a translator. Since it is coming more and more complicated I will try to explain better what I'd like to implement. I need to specify a new java like language. This language must implement all structure of a java…
2
votes
1 answer

Apply dynamic list of templates to an argument

I need apply a variable sequence of templates to an argument. The template secuence is determined in runtime in the controller layer, and these templates are applied to only one argument like: arg:tpl1():tpl2():...:tplN() In resume, I need apply a…
2
votes
2 answers

Does StringTemplate 4 require template files on disk?

I am trying to find an HTML template solution for a Java web application. I need the flexibility to load templates from whatever sources I choose as most of them will likely be in a custom database. In my search I stumbled upon StringTemplate 4,…
Bernard Igiri
  • 1,272
  • 2
  • 18
  • 33
2
votes
1 answer

StringTemplate: skipping trailing coma when generating a Javascript array

I'm generating a Javascript array in StringTemplate 4 and I'm having trouble skipping the trailing coma after last element. Each item gets generated using a template and then I want to separate them using comas to create an array in the form: […
machinery
  • 3,793
  • 4
  • 41
  • 52
2
votes
2 answers

dynamically function call from String template

Is it possible to call a function of Java class through dynamically generated function from StringTemplate ? for instance, following is a Java class with three functions public class RegionManager { public static List getCenter(){ …
user-517752
  • 1,188
  • 5
  • 21
  • 54
1
vote
0 answers

How to pass multiple parameters to subtemplate on StringTemplate4

I'm trying to call a subtemplate where I nedd to pass two expressions as parameter and deal with those parameter with a CustomRenderer. When calling a subtemplate + CustomRenderer with one parameter it's done by calling a method from the template…
Ruben Trancoso
  • 1,444
  • 5
  • 27
  • 55
1
vote
1 answer

StringTemplates, how to create a group of templates in code

I'm new to StringTemplates and try to figure out how to build a group of templates from a source other than files (it's actually in a database). I miss something like (pseudocode): STGroup group = new STGroup(); group.addTemplate("name", args, "...…
Stefan Steinegger
  • 63,782
  • 15
  • 129
  • 193
1
vote
2 answers

Java StringTemplate Using File From Outside Directory

I have a directory structure like this: Templates/ ├── Foo/ │ ├── Foo.st ├── Signature.st Here's what the Foo.st looks like:
Richard
  • 5,840
  • 36
  • 123
  • 208
1
vote
1 answer

ST4 iterate a list with an index

So I have a list that is iterated over like so: body(foo) ::= "<\n>}>" bar(x) ::= "[:]" I'd like to use the index. bar(x) ::= "[::x.value>]" I saw that there is an and index token, but I…
Novaterata
  • 4,356
  • 3
  • 29
  • 51
1
vote
1 answer

Filter out empty strings in ST4

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…
barbalion
  • 165
  • 7
1
vote
1 answer

Applying ST to Antlr4-generated parse trees

Generated accessors of parse tree context nodes do not conform getProperty()/isProperty()/hasProperty() standard. As a result, ST can’t be applied to the parse tree directly. There seems to be 3 alternatives to apply ST to the generated parse…
Y2i
  • 3,748
  • 2
  • 28
  • 32