stringtemplate

C# StringTemplate - how to set eol character

I'm using the C# version of the StringTemplate library (http://www.stringtemplate.org/) to generate C++ code. My templates work fine, until I started using the <attribute:template(argument-list)> syntax to apply templates to multiple values in a 'list' ('multi-valued-argument' if I'm correct in the StringTemplate lingo). From that mo...

Best Template Engine for ASP.NET MVC

I am exploring ASP.NET MVC and I wanted to add jQuery to make the site interactive. I used StringTemplate, ported to .Net, as my template engine to generate html and to send JSON. However, when I view the page, I could not see it. After debugging, I've realized that the $ is used by the StringTemplate to access property, etc and jQuery u...

Does StringTemplate work with Struts?

I would like to use a template engine in my struts web application. Therefore I would like to use StringTemplate, but have no idea how to implement in Struts. ...

Any lightweight templating solutions in Java with support for conditional formatting?

I'm using MessageFormat to format some addresses with a template like this: "{0}\n{1}\n{2}\n{3}, {4} {5}" where 0 = street 1 1 = street 2 2 = street 3 3 = city 4 = state 5 = zip Most of these fields are optional when captured. How do I avoid having an empty line when for instance, there is not street 3? I could use a template lik...

How to integrate the StringTemplate engine into the CherryPy web server

I love the StringTemplate engine, and I love the CherryPy web server, and I know that they can be integrated. Who has done it? How? EDIT: The TurboGears framework takes the CherryPy web server and bundles other related components such as a template engine, data access tools, JavaScript kit, etc. I am interested in MochiKit, demand C...

How to build your own lexical analyzer for StringTemplate?

Hmm, sounds easy enough but after looking at the ones that come with StringTemplate, there is no way this is easy for me the average developer. Where does one start? From doing some more digging it seems to accomplish this one would also have to learn the ANTLR tool to create the language file? Is that correct? Or can I just copy one t...

Which Java MVC frameworks integrate easily with StringTemplate?

It's hard to see how StringTemplate integrates easily (or not) with popular Java web MVC frameworks. Which Java MVC frameworks integrate easily with StringTemplate? A good answer: mentions one solution to integrate with a framework, includes a link to something useful and applicable, like: a tutorial, or documentation, or a referenc...

Zebra striping built-in to stringtemplate?

In this example I am striping with code before passing in to the template, I just wanted to make sure I wasn't missing some already built-in stringtemplate functionality. using System; using System.Linq; using Antlr.StringTemplate; using Microsoft.VisualStudio.TestTools.UnitTesting; namespace Tests { [TestClass] public class R...

StringTemplate ListDictionary Iteration

I'm trying to iterate over a ListDictionary (C# StringTemplate) in a template and have each list item invoke another template: DataDefAssign(cols) ::= << <cols.keys: { k | <PropDef(name=<k>, type=<cols.(k)>) }> >> The above template does not generate anything. If I inline an anonymous template instead of trying to invoke the PropDef t...

Which Java HTML templating technology works in a way that is closest to Ruby (erb/haml)?

Among the Java templating solutions such as Apache Velocity, Freemarker, Hamlets, Tapestry, StringTemplate, JSP, JSP Weaver (others?) which would most closely approximate the conciseness and simplicity of similar HTML templating solutions in Ruby - haml/erb. I'm concerned both with the syntax of the templating engine as well as how simpl...

StringTemplate - How to iterate through list of business objects and output simple html?

Hello, I've just started using StringTemplate in my C# project. I went through the documentation, but I can't seem to find a way to implement this simple scenario: I have a list of simple business objects (let's say Orders) and I want them displayed inside a UL tag inside my html template. So, my .st template looks like this (pseudo-c...

How to force StringTemplate to evaluate attribute within attribute?

I have the following code: StringTemplate st = new StringTemplate("$msg$"); st.SetAttribute("msg", "Hello $usr$"); st.SetAttribute("usr", "Jakub"); Console.WriteLine(st); // current output: "Hello $usr$" // expected output: "Hello Jakub" Do anybody know how to force StringTemplate to evaluate $usr$ attribute? ...

string template and medium trust hosting

Hi my problem is with string template and operating under medium trust that godaddy enforces. Has anyone had the same problem and what did you do? Moving to another host is a solution so feel free to name one. Modifying the code will be the last thing I want to do since it is mostly done and it will set me back some time. I have read ...

Example of subclassing string.Template in Python?

I haven't been able to find a good example of subclassing string.Template in Python, even though I've seen multiple references to doing so in documentation. Are there any examples of this on the web? I want to change the $ to be a different character and maybe change the regex for identifiers. ...

Is it possible to successfully merge transitive assembly references with ILMerge?

I'm trying to use ILMerge to internalize some transitively referenced assemblies into an assembly I'm referencing to eliminate conflicts with those transitive dependencies elsehwere in my project. In particular, I'm referencing Antlr3.StringTemplate (hereafter referred to as AS, available here: http://www.stringtemplate.org/download.htm...

String Template with object of object

I want to build my HTML template like $GetCurrencyType(Customer.currencyType)$. Here Customer is the object and currencyType is the integer property and GetCurrencyType is the method which return currency symbol as string. GetCurrencyType was in another class and i called the method using local instance. in C# code just I'll call st.Set...

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 and passing the collection through as a parameter, it fails to render at all. The follo...

Conditionals in Antlr String Templates

We are using Antlr StringTemplates to give control over how a Entity's Name is output. The basic Stringtemplate is $FirstName$ $Initial$ $LastName$, $Suffix$, $Degree$ I want to add some smarts to that template so that the commas are only output when necessary i.e. The first comma is only output when there is a Suffix or Deg...

How do I use an IF statement in a loop with StringTemplate

This displays nothing: $Articles:{ $if(i!=1)$ display in between articles $endif$ $it.Text } This displays as expected $Articles:{ display in between articles $it.Text } Any ideas on how to get this working? ...

struts2 StringTemplate support

I'm looking for a struts2 StringTemplate result type. Given an action result I'd like to render the html using StringTemplate. There are struts2 result types for Velocity, FreeMarker etc but I haven't been able to find one for StringTemplate, Google doesn't help. Has anyone seen such result type? Or perhaps this is something that mysteri...