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

Can't access ViewDataDictionary object properly on StringTemplate

I'm playing with StringTemplate version 3.1.4.6002 as a view engine for an MVC project. I can't seem to access an object being passed to the template and have it render on a webpage. So basically, I have the the following in the controller (in C#):…
Noble_Bright_Life
  • 569
  • 3
  • 9
  • 16
0
votes
1 answer

antlr: how to use String.format inside action

I have the a rule with an action defined as follows: metric_expr : metric=NAME ('AS' label=NAME)? {System.out.println(String.format("%s: %s", metric, label));} ; I got the error says: error(146): com\foo\bar\PRL.g:65:54: invalid StringTemplate…
Gelin Luo
  • 14,035
  • 27
  • 86
  • 139
0
votes
1 answer

Issue with Antlr Stringtemplate V4 ArrayList iteration

heres my test in java public class person { public String name; public int age; public String getName() { return name; } public int getAge() { return age; } } In my function I create a number of person objects and add it into an…
pvee
  • 25
  • 1
  • 5
0
votes
1 answer

How can StringTemplate import directory be used?

I wrote a sample java file that is located in /src folder. public class Main { public static void main(String[] args){ STGroupFile StgFile=new STGroupFile("template.stg"); StgFile.delimiterStartChar = '$'; StgFile.delimiterStopChar =…
Michail Michailidis
  • 11,792
  • 6
  • 63
  • 106
-1
votes
1 answer

What does the dollar symbol do in a back-ticked JavaScript string?

Why we use $ sign why we can't print it like second program? let animals = 'elephants, eagles, owls, and tigers'; console.log(`${animals.slice(11,17)} and ${animals.slice(19,23)} are cool birds`); 2nd program let ani = 'elephants, eagles, owls, and…
Izza Ijaz
  • 9
  • 1
-1
votes
1 answer

String template to regex in python

I am trying to make a parser of file paths that follow an arbitrary naming convention. I am wanting to take an arbitrary string.Template and get the re.Match.groupdict() corresponding to a string that follows the string.Template. I would also like…
-1
votes
1 answer

StringTemplate 4 set condition from java

How to set ST4 condition from Java? I have following ST4 template templateExample(param) ::= << $if (condition)$
  • $param$ is true
$else$
  • $param$ is false
$endif$ >> While the main class is public static void…
Timothy
  • 855
  • 1
  • 13
  • 29
-1
votes
1 answer

StringTemplates exception

I have java-code: StringTemplate message = new StringTemplate("Hello, $name$"); message.setAttribute("name", "Ann"); But I have exception: java.lang.NoClassDefFoundError: antlr/TokenStream java.lang.ClassNotFoundException:…
somebody
  • 1,077
  • 5
  • 14
  • 32
-2
votes
2 answers

How to specify a default value for unspecified variable in Python string templates?

Consider the following code from string import Template s = Template('$a $b') print(s.safe_substitute(a='hello')) # $b is not substituted print(s.substitute(a='hello')) # raise error What I want is that I can specified a default value for all…
link89
  • 1,064
  • 10
  • 13
1 2 3
17
18