Questions tagged [stringtemplate]

A templating language which strictly enforces model/view separation

StringTemplate is a Java based templating language (with ports in Python, C#, Ruby, Scala) that strictly enforces model/view separation. See the whitepaper for more details.

264 questions
0
votes
1 answer

Expression not working in stringTemplate

Hi I'm using StringTemplate version 3.2.1 and Java. I'm passing in an ArrayList to the Stringtemplate but its not picking it up. I want to iterate through the array depending on the number of values. ArrayList test = new…
user1946337
  • 151
  • 2
  • 10
0
votes
2 answers

StringTemplate4 if conditional with length

I need to generate the following kinds of code with StringTemplate4: methodFoo0(Connection conn); methodFoo1(Connection conn, int arg1); methodFoo2(Connection conn, int arg1, int arg2); etc. The "Connection conn" part is always present so I am…
Marcus Junius Brutus
  • 26,087
  • 41
  • 189
  • 331
0
votes
0 answers

Emacs mode for StringTemplate

Is there an Emacs mode available for the StringTemplate Java template engine ?
Marcus Junius Brutus
  • 26,087
  • 41
  • 189
  • 331
0
votes
1 answer

Getting the length of a String value in StringTemplate

According to the documentation you can reference properties of objects in the format. I was hoping this would let me check the length of a String, but it doesn't seem to work. I think this is because the method is String.length(),…
DaoWen
  • 32,589
  • 6
  • 74
  • 101
0
votes
1 answer

Passing collection parameters when calling templates in StringTemplate

Run into a bit of a snag using StringTemplate today. Were using StringTemplate 3.1 with .Net 3.5. If I have a template that renders a collection of items, it renders fine if I call it directly. However, if I call that template from another template…
bcowcher
  • 189
  • 1
  • 5
0
votes
1 answer

What is the equivalent in v4 of StringTemplate.setAttributes(Object) in v3?

v4 provides an API: ST.add(String, Object). I couldn't find the v3 API setAttributes(Object) in v4. I used ST.add("root", JSONObject). An exception occures: java.lang.IllegalArgumentException: no such attribute: root at…
0
votes
1 answer

ANTLR - StringTemplate - CamelCase

What is the best pattern (language independent, for retargetable generation code) to translate antlr token to camel case StringTemplate attribute in a tree conversion? Example: My DSL has MY_FIELD definition and in the StringTemplate output I need…
0
votes
1 answer

What is the correct stringtemplate Group Syntax to build a group from a String?

I am trying to build a STGroup from a String but it is complaining about invalid characters and missing templates: final String templates = "a(x) ::=
  • $x.fname$ $x.lname$
  • \n" + "b(persons) ::=…
    user177800
    0
    votes
    0 answers

    Update Maven Repo

    Can you update http://mvnrepository.com/artifact/org.antlr/ST4 ? The latest version there is 4.0.4 and you all are on 4.0.6. FYI: the ONLY reason I am asking this here in SO is due to this page: http://www.stringtemplate.org/support.html which…
    JoeG
    • 7,191
    • 10
    • 60
    • 105
    0
    votes
    2 answers

    Filtering a multivalued attribute in StringTemplate

    I have a template which uses the same multivalued attribute in various places. I often find myself in a situation where I would like to filter the attribute before a template is applied to the individual values. I can do this:…
    j_maly
    • 1,091
    • 1
    • 13
    • 27
    0
    votes
    1 answer

    Validation of StringTemplate Templates

    I am using StringTemplate v4 and need to validate user generated templates. Since I am new to StringTemplate I was wondering if there is an easy way to validate templates. Thanks.
    evermean
    • 1,255
    • 21
    • 49
    0
    votes
    2 answers

    Antlr StringTemplate

    How can I prevent new lines in StringTemplate? For example myAssigns(isConst, myType, myName,exp1,exp2) ::= << const []= ; >> works and keeps the translation on one line, but it…
    Pinsickle
    • 623
    • 2
    • 10
    • 20
    0
    votes
    1 answer

    StringTemplate-4: Cannot render expr property

    According to the StringTemplate 4 wiki, I should be able to display an expr property, but I cannot. I'm using StringTemplate4 with jython. Here's my template file, test.st: test(persons, person) ::= << …
    MD6380
    • 1,007
    • 4
    • 13
    • 26
    0
    votes
    0 answers

    Mixture of types using string template

    I am using a string template group to create a java source file. Several of the classes extend another class and need to call a super method that can contain a mixture of types, normally int, String and Enum. super(list) ::=…
    The Cat
    • 2,375
    • 6
    • 25
    • 37
    0
    votes
    1 answer

    I can't get StringTemplate to indent

    I have the following StringTemplate group group RPInstr; before(firstStat) ::= << <{<[beforeEnteringInstr(),firstStat]; anchor, separator="\n">}; anchor> >> beforeEnteringInstr() ::= "before();" I am trying to make the first statement of a…
    1 2 3
    17
    18