[antlr-interest] Fwd: ST#, attribute renderers, and format
Micheal J
open.zone at virgin.net
Fri Feb 29 16:18:26 PST 2008
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