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

How do I generate indentation events when using '<% ... %>' bounded templates in StringTemplate

This is related to https://www.stringtemplate.org/api/org/stringtemplate/v4/AutoIndentWriter.html https://github.com/antlr/stringtemplate4/blob/master/src/org/stringtemplate/v4/AutoIndentWriter.java If I have a template like... foo(bar) ::= << { …
phreed
  • 1,759
  • 1
  • 15
  • 30
0
votes
1 answer

In a StringTemplate how to temporarily suppress automatic indentation?

In a StringTemplate how to temporarily suppress automatic indentation? Suppose a template: fooTemplate() ::= << I want this to be indented normally. # I do not want this line to be indented. >> So you can understand the motivation. I am…
phreed
  • 1,759
  • 1
  • 15
  • 30
0
votes
0 answers

StringTemplates for C++

There are plenty of Antlr4 grammars available, e.g. https://github.com/antlr/grammars-v4/tree/master/cpp As a use-case consider parsing a C++ source file, using the corresponding Antlr4 grammar, and writing the resulting AST back out with…
phreed
  • 1,759
  • 1
  • 15
  • 30
0
votes
0 answers

How do I add documentation to a StringTemplate group file?

It appears that the is only supported within a template. Is the use of this comment syntax the recommended way to add documentation to a StringTemplate(4) group file?
phreed
  • 1,759
  • 1
  • 15
  • 30
0
votes
1 answer

How to use string template

I am trying to use ANTLR to create understand how grammar works. I have started playing with ANTLR and created a simple addition program. Below is my simple grammar. grammar addition; expr: NUMBER PLUS NUMBER; NUMBER: [0-9]+ PLUS: '+'; SPACE : '…
0
votes
1 answer

Loading A STv4 Template From a Jar

I'm having some trouble figuring out how to migrate my code to use org.stringtemplate.v4 . I have a single template file in a 'templates' folder under src/main/resources. Nothing fancy going on. I just need to load the template, set a few…
pbuchheit
  • 1,371
  • 1
  • 20
  • 47
0
votes
0 answers

Jdbi string template engine conditional with expression

I'm trying to use jdbi string template engine with an expression in an if condition. I tried different versions: but I haven't found a way…
TheOni
  • 810
  • 9
  • 26
0
votes
0 answers

How do I prevent the extra separator?

Given the code ST4 C# code below, how do I prevent the trailing separator (',') from appearing in my output? The trailing separator won't appear if there aren't items to skip after the first item is output (e.g. if the third item in the list isn't…
Brian
  • 305
  • 1
  • 11
0
votes
0 answers

How to map Object field:value to attribute list?

ST has add(String name, Object value), but what if i want to populate ST attributes with data from POJO? class User { public String id; public String link; public String key; } So, i want to type something like ST.add(new User(...)) and get…
callmedope
  • 83
  • 1
  • 9
0
votes
0 answers

Building a Netbeans lexer for ANTLR 4.5 and String Template 4 grammars

I have been trying to build a Lexer in Netbeans 8.2 to have the correct syntax for String Template v4 files. The problem is that Netbeans modules only have access to ANTLR 3.3 or 4.5 libraries, and I cannot find any String template v4, either pre…
0
votes
1 answer

StringTemplate rendering map as literal value

Using org.stringtemplate.v4.ST I am trying to render this template: $if(foo.map)$Foo Map: : }; separator="\n">
$endif$ When the st.render() method is invoked, this is printed out: Foo Map:
Hooli
  • 1,135
  • 3
  • 19
  • 46
0
votes
1 answer

ANTLR4 - targets without nested classes

I am trying to extend ANTLR4 with a new PHP target and have a problem with the StringTemplate file (.stg): In the StringTemplate file the Parser is defined by the template Parser_. Parser_ contains the following rule :
0
votes
1 answer

Code generation using string template

I am trying to use string template to generate Pig/Hadoop code. Since I am a novice I couldn't figure it out myself. Any help will be appreciated. I have a List of LocalDate like one show below List dates = Arrays.asList("20100101",…
user3138594
  • 209
  • 3
  • 9
0
votes
1 answer

how to install ANTLR 4.5.3 tool jar for eclipse-plugin development?

I need to use ST4 for my eclipse plugin development project. As stated by antlr guys, the last version 4.5.3 is osgi ready and have st4 in his tool package. How can I install it, so it appear in the dependencies list of my plugin manifest ? Thanks.…
kasor
  • 179
  • 1
  • 5
0
votes
1 answer

Stringtemplate - use conditionals without adding newlines to the output, and still keep templates legible?

I have something like this: properties(attributeInfo) ::= << private ; >> parameters(attributeInfo) ::=…
rbellamy
  • 5,683
  • 6
  • 38
  • 48