stringtemplate

Multiple skins in ASP.NET MVC using StringTemplate

I am considering the StringTemplate view engine for my ASP.NET MVC application. This application will be built with one skin, but I then expect many more, often very similar skins to be developed for it. This is primiarly the reason for my choice of StringTemplate as the view engine, as there will be zero logic in the views. In my head,...

"x of n" in StringTemplate from a single int/count

I'm trying to print out generate shipping labels, and I know how many I want. So given that I know n, how do I print "x of n" for x=1 to n? What I'm wanting to do is have an expansion template that will take n and provide the x and n variables to the template I shall pass (StringTemplate is a functional-type templating language, so thi...

Using css in a StringTemplate Email

Hi, I'm currently using StringTemplate to create my emails on the fly and its proven very easy to use in creation of the email. However, I'm trying to apply some styling to my emails and dont seem able to do this in the normal manner. I can style parts of the mail if I write it inline, eg. <p style="color:red;">Hello again, $name$ !</...

StringTemplate can not render attribute of LINQ to SQL class

i use GUI tool of vs2008 to generate some LINQ to SQL class, my problem is StringTemplate can not reach attributes of those model $persons:{ <li>$it.name$</li> }$ it printed: <li></li> <li></li> <li></li> name is public property of Person model. If i create a person class by myself, and the same attributes, StringTemplate can get i...

Complex email templates

I saw a thread on email templates, with maildefinition class being to limited, bitethebullet.co.uk xml based for simple field/list replacement, and nvelocity and stringtemplate for more complex tasks. Is there some example code out there for nvelocity and/or stringtemplate (c#) used for email templates? mike ...

Using $ as delimiter in StringTemplate from ANTRL rewriter grammars

I'm trying to write an ANTLR3 grammar that generates HTML output using StringTemplate. To avoid having to escape all the HTML tags in the template rules (e.g. \<p\><variable>\</p\>), I'd prefer to use dollar as the delimiter for StringTemplate (e.g. <p>$variable$</p>). While the latter seems to be the default when StringTemplate is used...

nested loop in StringTemplate

Im interested in writting something similar to a nested loop using StringTemplate template engine. In C# have a HashTable of which each Key contains List of Document objects, each Document has a title and source. I would like to list at the beggining of an email, a summary of the document titles per source. <h1>Summary</h1> <h2>Source A...

stringtemplate .net dynamic object

Hi I am using string template to render some content, but the content may be variable so not sure how to pass it in (using .net / c#) Basic idea is I have a List> which need to end up as parameters, e.g. List<KeyValuePair<string, object>> ret = new List<KeyValuePair<string, object>>(); ret.Add(new KeyValuePair<string, object>("elem1",...

Document generation template engine for production usage NVelocity vs StringTemplate

For building a document generation engine what would be the primary .NET framework to be used in production. The 2 main ones I see are NVelocity and StringTemplate. NVelocity in all forks to be almost unsupported at this point where as ST been active atleast as of this year. Are either or both of these stable for use in production (if n...

StringTemplate Variable with Object Properties

I am starting to use StringTemplate for the first time, and am stuck trying to figure out how to get StringTemplate to do something like the following: article.st $elemenets:article/elements()$ article/elements.st $if($it.is_type)$ $it:article/type()$ $elseif($it.is_type2)$ $it:article/type2()$ // also tried: $it.value:article/type2...

StringTemplate view engine and Areas

Hello I have a problem combining StringTemplate view engine and Areas, i don't know what to do so paths can be recognized. Anyone tried that combination? ...

Format date in String Template email

I'm creating an email using String Template but when I print out a date, it prints out the full date (eg. Wed Apr 28 10:51:37 BST 2010). I'd like to print it out in the format dd/mm/yyyy but don't know how to format this in the .st file. I can't modify the date individually (using java's simpleDateFormatter) because I iterate over a col...

StringTemplate bad performance

I'm using StringTemplate to generate some xml files from datasets. Sometimes I have more than 100,000 records in the dataset that is enumerated by a loop in a template. It goes very slow (15-20 secs per operation) so performance is not good for me. This is an example how I use ST to render a report: using (var sw = new StringWriter()) ...

is it possible to add a string template to views in a .net mvc project?

Hi, I have a newbie question,, how do i add a string template to the views folder in a .net mvc project? I have added a reference to StringTemplate.dll and antlr.runtime.dll? but seems that is not enough. i.e. when i right-click on views and choose Add >> New Item i can't find a file with .st extension in the list that i get... how d...

Using Scala and StringTemplate, how do I loop through a Map

I have my environment setup nicely using Scala, StringTemplate within the Google AppEngine. I am having trouble looping through a Map and getting it to display in the template. When I assign a simple List of just Strings to the template it works using: In Scala Servlet: var photos = List[String]() //... get photo url and title ......

StringTemplate: Loading a Template from disk?

I am using StringTemplate in c# and following code to load a template from a subdirectory of my application. StringTemplateGroup group = new StringTemplateGroup("myGroup", "/tmp"); StringTemplate query = group.GetInstanceOf("Sample"); query.SetAttribute("column", "name"); Console.WriteLine(query); I have a template file Sample.st in t...

StringTemplate conditional statement can't support similar id>0?

Recently I use stringtemplate,I noticed StringTemplate can't support complex conditional,similar value>1 or value="menu" etc. who can give me a advise how to work?thanks. ...

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 below: StringTemplateGroup group = new StringTemplateGroup("views", viewPath); ...

Why StringTemplate could be slow?

I'm using StringTemplate as view layer for my web application. Recently I've measured how much time is spent rendering pages and it's around 50ms for simple pages and 500ms for complex pages. This is too much for my needs, so I'm looking for a way to improve ST's performance. How can I do this? Most of the time is consumed by the String...

Performance of creating XML using StringTemplate?

I'm developing an application which uses different components to create an XHTML document, I used StringTemplate for creating the document data of the components and then combined them into a one large document. This is an example of a component: public class BoxImpl extends AbstractContainerImpl implements Box { private static fin...