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
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

Linking Xtext with StringTemplate code generator

In my current project, I am trying to link the DSL specification written in xtext and code generator written in StringTemplate. for instance, the syntax of my DSL specification is as follows. I am entering this information through nice editor…
user-517752
  • 1,188
  • 5
  • 21
  • 54
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

Install stringtemplate3 for python

I tried to run Python/cminus example. From http://pypi.python.org/pypi/stringtemplate3/3.1, I installed stringtemplate3 for python with sudo python setup.py install. When I run cminus.py that starts with this code. import sys import antlr3 import…
prosseek
  • 182,215
  • 215
  • 566
  • 871
3
votes
2 answers

Output DataTable using StringTemplate

I'm trying to implement a method that will accept DataTable with StringTemplate and return string representation of data. I found how to do this here and here, but it doesn't work for me. Example code: // Here can be any table with any number of…
kyrylomyr
  • 12,192
  • 8
  • 52
  • 79
3
votes
1 answer

What's the difference between string template and log framework's placeholder in Kotlin?

And now, I am trying to rewrite my java application in Kotlin. And then, I met the log statement, like log.info("do the print thing for {}", arg); So I have two ways to do the log things in Kotlin like log.info("do the print thing for {}", arg) and…
Sheldon Wei
  • 1,198
  • 16
  • 31
3
votes
3 answers

How to format decimal numbers with StringTemplate (ST) in Java?

I am using StringTemplate in Java. I would like to render decimal number with a certain precision (e.g. 3 digits after the decimal point). Is it possible to for the ST object to do it? And how? Edit: to clarify, this is especially relevant when…
daphshez
  • 9,272
  • 11
  • 47
  • 65
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
2 answers

Where to get Python ANTLR package to use StringTemplate?

I'd like to do some code generation, and StringTemplate looks like a pretty good tool for the job. I easy_installed stringtemplate3 from PyPi, but when I try to import it I get: ImportError: No module named antlr I am confused by this because I…
John Salvatier
  • 3,077
  • 4
  • 26
  • 31
3
votes
1 answer

ANTLR Tree Grammar and StringTemplate Code Translation

I am working on a code translation project with a sample ANTLR tree grammar as: start: ^(PROGRAM declaration+) -> program_decl_tmpl(); declaration: class_decl | interface_decl; class_decl: ^(CLASS ^(ID…
nobeh
  • 9,784
  • 10
  • 49
  • 66
3
votes
1 answer

How to use partial templates with map in StringTemplate?

I've got a map of city names => distance-from-origin. I'd like to use a partial with this map, and create something like so:
  • city1: distance1
  • city2: distance2
  • city3: distance3
What is the canonical way to do…
Alex Baranosky
  • 48,865
  • 44
  • 102
  • 150
3
votes
1 answer

Is it possible to use ant's antlr task to do code generation with stringtemplate?

Is it possible to use ant's antlr task to do code generation with the stringtemplate library? If not, is it better to just execute a java class from command line to code gen w/ stringtemplate? I've found this link which is close to what I want, but…
Joyce
  • 1,431
  • 2
  • 18
  • 33
3
votes
1 answer

StringTemplate - How to iterate through list inside list?

Let's say i've list of objects that i want to iterate in stringTemplate. the object look like that: public class a1 { private String name; private String value; private List a2list; public String getName() { return name; } public void…
koby
  • 665
  • 2
  • 6
  • 15
3
votes
3 answers

Break the string template into two lines without appending new line or whitespaces

I have following string tempalte: const someUrl = `/${currentLocale}/somecategory/${category.get('slug')}/${post.get('iD')}/${post.get('slug')}`; The problem is that this line is too long and I have to break it, but putting simple enter in the…
hsz
  • 148,279
  • 62
  • 259
  • 315
3
votes
1 answer

Hierarchical data in StringTemplate

I am trying to create a hierarchical document using StringTemplate. For example, a list of directories: \alpha \file1 \file2 \beta \file3 \gamma \file4 \file5 \file6 Is this even possible with StringTemplate?
James
  • 33
  • 2