[stringtemplate-interest] Re : Re : Helpers

Matthieu Wipliez mwipliez at yahoo.fr
Fri Oct 22 00:58:13 PDT 2010


Nice one, I wasn't aware of that feature :-)
This definitely looks better than my $if (row.even)$ solution!

Cheers,
Matthieu



----- Message d'origine ----
> De : Brian Clapper <bmc at clapper.org>
> À : "stringtemplate-interest at antlr.org >> "stringtemplate-interest at antlr.org"" 
><stringtemplate-interest at antlr.org>
> Envoyé le : Jeu 21 octobre 2010, 18h 41min 03s
> Objet : Re: [stringtemplate-interest] Re :  Helpers
> 
> On 10/21/10 12:34 PM, Matthieu Wipliez wrote:
> > Hi Philip,
> > 
> > You cannot perform arithmetic computations with StringTemplate, so  these 
>must be 
>
> > put in the model:
> > 
> > 1) I would say add a  method isEven() in the model and use
> > class="$if  (row.even)$even$else$odd$endif$"
> > 
> > 2) You must define a method  getHalfPrice() { return price / 2; }
> > and use it in the  template.
> 
> There's a third option: Use the explicit StringTemplate support  for 
>alternating
> values. See
> 
>http://www.antlr.org/wiki/display/ST/Expressions#Expressions-ApplyingAlternatingTemplatesToMultiValuedAttributes
>s
> -- 
> -Brian
> 
> Brian Clapper, http://www.clapper.org/bmc/
> Beauty and harmony are as  necessary to you as the very breath of  life.
> _______________________________________________
> stringtemplate-interest  mailing list
> stringtemplate-interest at antlr.org
> http://www.antlr.org/mailman/listinfo/stringtemplate-interest
> 


      


More information about the stringtemplate-interest mailing list