[antlr-interest] ANN: C# StringTemplate - ST# v2.3b5 now available

Micheal J open.zone at virgin.net
Mon Feb 6 11:08:29 PST 2006


A beta version of ST# v2.3b5 - a new template library written in C# that
enforces Model-View separation - has been released on the
www.stringtemplate.org website. ST# is developed in C# (using ANTLR 2.7.6)
but can be used with projects developed in other languages such as VB.NET,
C++.NET, J# etc.

For those unfamiliar with them, a template engine is at it's most basic, a
code generator that emits text using templates. These templates are really
just "documents with holes". The "holes" are markers for where you can stick
values.

"C# StringTemplate" (or ST#) is a new template library that breaks up your
templates into chunks of text and attribute expressions, which are by
default enclosed in dollar signs (e.g. $attribute-expression$). Everything
except attribute expressions is treated as literal text and copied verbatim
to the output when you call the method ToString() on a StringTemplate
instance.

ST# v2.3b5 is feature complete with respect to StringTemplate v2.3b5 for
Java and includes an *alpha* release of a StringTemplate visualizer. It has
a C#-fied API and features a unique and useful template loader abstraction.
You can download it from this page on the StringTemplate website where you
can also find more information about the StringTemplate template library:

http://www.stringtemplate.org/share/list


-------------- next part --------------
C# StringTemplate v2.3b5 - a template library that enforces Model-View separation

5 February, 2006

Kunle Odutola		: kunle UNDERSCORE odutola AT hotmail DOT com
Micheal Jordan


1. INTRODUCTION 

A template engine is at it's most basic, a code generator that emits text 
using templates. These templates are really just "documents with holes".
The "holes" are markers for where you can stick values. 

"C# StringTemplate" (or ST#) is a template library that breaks up your 
templates into chunks of text and attribute expressions, which are by 
default enclosed in dollar signs (e.g. $attribute-expression$). It ignores 
everything except attribute expressions. Everthing else is treating it as 
just text to and is simply copied verbatim to the output when you call the 
method ToString() on a StringTemplate instance.

We hope you find ST# delightful and useful even but, as per the license 
under which you may use it, this software is not guaranteed to work. 
See LICENSE.TXT for the full text of the license.

----------------------------------------------------------------------
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
----------------------------------------------------------------------


2. WHAT'S IN THE PACK?

This distribution contains four projects and the project files needed to 
build them with Microsoft Visual Studio 2003. The projects are:

	1. StringTemplate			- the core ST# runtime library

	2. StringTemplateTests		- unit tests for the ST# library above

	3. StringTemplateTreeView	- a library for visualizing StringTemplates
								  [Alpha quality release - not reliable]

	4. StringTemplateViewer		- a StringTemplateTreeView demo app
	
In addition the Lib sub-directory contains copies of the ANTLR 2.7.6 runtime 
assemblies. ST# *needs* ANTLR version 2.7.6 or later but, you should probably 
use your own versions of these assemblies if you already have ANTLR 2.7.6.

2.1 Dependenicies

All projects have a dependence on ANTLR 2.7.6 as stated above. In addition, 
StringTemplateTests has a dependency on NUnit v2.2+.


3. BUILDING ST#

If you wish to re-build ST# for any reason, this is what you ned to know.

a) This release of ST# was built with ANTLR 2.7.6. If you change any of the 
ANTLR grammar files supplied with ST#, you will need to use the ANTLR tool to 
regenerate the corresponding C# source files for the Lexer/Parser/TreeParsers. 
The grammar files - all named <something>.g - are in:
	%ST_DIR%\StringTemplate\Antlr.StringTemplate.Language\

b) Then, just use the supplied VS.NET project files to build the projects. 

NOTE: Some of the ANTLR grammar files above trigger a curious bug in ANTLR 2.x 
that can only by fixed by hand. The errors are related to the redefinition of 
a variable. There are about 4-6 such manual fixes required although the number 
of error/warning messages you get may be more than that. Errors are:

	CS0128: A local variable named 'variable' is already defined in this scope
	CS0136: A local variable named 'var' cannot be declared in this scope because 
	        it would give a different meaning to 'var', which is already used in 
	        a 'parent or current' scope to denote something else


4. ST# STATUS

This release of ST# is a beta release (ST# TreeView visualizer is an Alpha release). 
ST# itself is mostly feature complete for the upcoming 2.3 release but expect a few 
rough edges. 

There are currently about 2-3 failures in the unit test suite out of about 190 cases.


Don't forget to visit the www.stringtemplate.org for further info. The mailing list is 
(currently) very low volume but has a very high Signal-to-Noise ratio. We'd like to 
hear about how you're using ST#.


Enjoy!

Kunle Odutola


More information about the antlr-interest mailing list