On Fri, 2011-10-28 at 11:31 +0200, Francesco Chicchiriccò wrote:
...
> Thorsten,
> see attached a patch for cocoon-stringtemplate and cocoon-sample that 
> should fix your issue about $if$ with StringTemplateTransformer.
> 
> In fact, I've checked that problems arise with transformer only, while 
> generator is safe in this respect; this happens because generator let ST 
> handle the whole file, while transformer doesn't. Transformer's approach 
> makes it able, however, to parse ST expressions in XML attributes as well.
> 
> If you want to try my patch, just apply it to fresh C3 sources, do an 
> "mvn clean install" of cocoon-stringtemplate and afterwards launch "mvn 
> jetty:run" under cocoon-sample: you will be able to watch results at 
> http://localhost:8888/string-template/generator and 
> http://localhost:8888/string-template/transformer.
> 
> I did not commit this yet because, as you can see from 
> StringTemplateTransformer's source, my patch is limited to "$if$" case, 
> and only when the whole $if$ evaluates to CDATA from XML point of view: 
> i.e. this work
> 
> <root>
> <a alt="$parameter$" href="$if(!booleanParameter)$
> expression evaluated to true
> $else$
> expression evaluated to false
> $endif$">link</a>
> </root>
> 
> while this does not:
> 
> <root>
> $if(!booleanParameter)$
> <element>expression evaluated to true</element>
> $else$
> <element>expression evaluated to false</element>
> $endif$
> </root>

I patched only the transformer, here my observation:
- the attribute approach works fine.
- the second one cuts of element generation from that point on.

it is a start. ;)

salu2
-- 
Thorsten Scherler <thorsten.at.apache.org>
codeBusters S.L. - web based systems
<consulting, training and solutions>
http://www.codebusters.es/

Reply via email to