[antlr-interest] Fwd: ST#, attribute renderers, and format

Christopher Brown chris77550 at gmail.com
Mon Mar 3 01:31:01 PST 2008


Hi,

I downloaded the build you linked to, and built it with Visual Studio
2005 using the supplied project file.  It seems to build correctly,
however I failed to replace the dependency in the version of
StringTemplate (3.0.1) downloaded from the www.stringtemplate.org
homepage in my test project...  In my test project, Visual Studio
warns me that (amongst others) DefaultTemplateLexer expects
antlr.runtime 2.7.x not 3.1, and it's getting a bit messy for me,
especially as I aim to go live with the code quite soon..!

Is there anywhere I can my hands on a compatible (nightly or
otherwise) build of ST# 3.1?  I had a look in
http://www.antlr.org/download/build/ and
http://www.stringtemplate.org/download/build/ and whilst antlr seems
active, the last build of StringTemplate is almost 6 months old.

In any case, I've subscribed to the correct list, don't know how I
missed it the first time (must've read too fast again or followed the
wrong link...).

I've been having a hell of a time figuring out the details of a bunch
of open source APIs on .NET, coming from a Java background.
NHibernate's a bit of a challenge outside the simple examples, so I'd
like to share my experience of that and string template at some point,
as better options than messy ASP.NET!

Thanks again,
Christopher


On 01/03/2008, Micheal J <open.zone at virgin.net> wrote:
> Hi,
>
>
>  > I guess I'm going to have to conclude that this isn't
>  > implemented and that maybe StringTemplate isn't a safe bet
>  > for anything other than Java.  :-(
>
>
> Why?. You would be quite wrong in any case. [*].
>
>
>  Incidentally, StringTemplate has it's own list. Try posting there for
>  StringTemplate specific discussions.
>  http://www.antlr.org/mailman/listinfo/stringtemplate-interest
>
>
>  Regarding your 'format' query, download the latest drop of ANTLR v3.1 beta
>  [http://www.antlr.org/download/build/antlr-2008-02-27.17.tar.gz]. The
>  included StringTemplate.dll file is ST# v3.1 beta and should have 'format'
>  implemented. Don't forget the required antlr.runtime.dll file.
>
>  Once you get going, you might want to revisit those wiki pages and provide
>  working C# examples to complement the Java ones.
>
>  Micheal
>
>
>  [*] The release of PyStringTemplate v3.1 was announced on the ST list a
>  little while ago...
>
>
>  > ---------- Forwarded message ----------
>  > From: Christopher Brown <chris77550 at gmail.com>
>  > Date: 22 Feb 2008 13:40
>  > Subject: ST#, attribute renderers, and format
>  > To: antlr-interest at antlr.org
>  >
>  >
>  > Hi,
>  >
>  >  The StringTemplate format option doesn't seem to be
>  > supported in  StringTemplate 3.0.1 for C#.  This is described here:
>  >
>  >  http://www.antlr.org/wiki/display/ST/Object+rendering
>  >
>  >  ...on the second part of the page, under the "Format Options" header.
>  >  As a quick reminder, it should allow me to register a
>  > formatter that  lets me use a template variable as follows:
>  >
>  >  $name;format="html"$
>  >  $name;format="javascript"$
>  >
>  >  ...so that I can apply appropriate escaping in the template,
>  > instead  of forcing the underlying data to the output format.
>  >  In many cases,  I'm rendering business objects, and I can't
>  > for example replace the  business object's string properties
>  > with some custom wrapper class.
>  >
>  >  I *can* register a basic attribute renderer, for example:
>  >
>  >  public class FmtRenderer : IAttributeRenderer {
>  >   public string ToString(object o) {
>  >   return o.ToString();
>  >   }
>  >   public string ToString(object o, string formatName) {
>  >   return formatName;
>  >   }
>  >  }
>  >
>  >  ...but only the first ToString(object o) method is ever called.
>  >  Suspiciously enough, the Wiki example page I referred to
>  > above doesn't  provide a C# example.
>  >
>  >  I've tried searching on the web, looking through the source
>  > code, and  so on, with no success.  How can I get this working?
>  >
>  >  Thanks,
>  >
>  > Christopher
>
>


More information about the antlr-interest mailing list