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

How to load StringTemplateGroups from the WEB-INF directory of a web archive

this question is somewhat related to this question: StackOverflow: Howto load a resource from WEB-INF directory of a web archive I want to use StringTemplate and want to load my templates via a StringTemplateGroup. Until know I use the method shown…
ThE_-_BliZZarD
  • 722
  • 2
  • 12
  • 26
3
votes
1 answer

Dictionary with dynamic entries in StringTemplate

I'm using StringTemplate 4.0.8 with Java. In the StringTemplate-4 documentation, it says that Dictionary strings can also be templates that can refer to attributes that will become visible via dynamic scoping of attributes once the dictionary…
Colophonius
  • 43
  • 1
  • 1
  • 6
3
votes
1 answer

How to let StringTemplate.NET to load template files with the extension ".dwt"?

The default template file extension of StringTemplate is ".st". Now I have several template files in a folder and their file extension is ".dwt". Is there a way to change the default template file extension and load all of them like…
Ethan
  • 33
  • 3
3
votes
2 answers

Function to get list of all identifiers in String Template (Python)

For standard library string template in Python, is there a function to get a list of all identifiers? For example, with the following xml file: Question ${PrimaryKey}: Cheat: ${orientation} the function will return…
Megool
  • 963
  • 2
  • 8
  • 29
3
votes
1 answer

StringTemplate indentation adds whitespace inside String

This is obviously a SSCCE. I have the following template file: xml(value)::=<< ^value^ >> ... with the following code: private static final String VALUE="alpha\nbeta"; public static void main(String args[]) throws…
Marcus Junius Brutus
  • 26,087
  • 41
  • 189
  • 331
3
votes
1 answer

How to retrieve error message in StringTemplate?

How can I retrieve a compile time error message from StringTemplate as a String? This code for instance: STGroup stg = new STGroup('<', '>'); CompiledST compiledTemplate = stg.defineTemplate("receipt", ""); if (compiledTemplate…
wvdz
  • 16,251
  • 4
  • 53
  • 90
3
votes
2 answers

In ST4/C#, can you register a new renderer without a TemplateGroup?

The only place the RegisterRenderer method appears is on TemplateGroup. But I just have a single template, supplied via a string, not multiple templates on the file system. Alternately, how can I use a TemplateGroup but supply the template(s) via a…
Deane
  • 8,269
  • 12
  • 58
  • 108
3
votes
1 answer

StringTemplate check if array is empty in java

How to check using the StringTemplate if the array is not empty? The example below doesn't work: 0)>
    }>
Other (not working) Exaple: String content = "list:…
czerasz
  • 13,682
  • 9
  • 53
  • 63
3
votes
1 answer

ANTLR:Translate the modified AST to java source code by stringtemplate

I use the grammar Java.g from the ANTLR wiki produces a lexer and parser for Java source files.Then use the following code to generate an abstract syntax tree (AST). ANTLRInputStream input = new ANTLRInputStream(new FileInputStream(fileName)); …
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

Comparing a String with a template like string

I am trying to write a program in which I have to do comparison between a list of strings with a template (which is essentially a string). I am not sure what is the term used but it is going to be more of log scraping program if that helps. Input…
Rox
  • 33
  • 1
  • 5
3
votes
2 answers

Stringtemplate with dollar sign

What is the best way to deal with dollar sign in stringtemplate. For example I need following template: You can purchase item $name$ for $5
Alexey
  • 517
  • 2
  • 10
  • 21
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
3
votes
1 answer

Decompose expression in base operation: ANTLR + StringTemplate

I am trying to write a translator for a Java like language to multiple languages. Right now I am facing 2 problems: First is to decompose complex expression in a sequence of basic operation and then translating them to destination language. For…
3
votes
1 answer

String Template: make all variable declaration global

I am trying to implement a translator using ANTLR+StringTemplate. I have a starting language that is java like and multiple destination language. I used the example:…