[stringtemplate-interest] A few notes on StringTemplate v4 beta

Terence Parr parrt at cs.usfca.edu
Sat Jan 22 12:08:14 PST 2011


On Jan 18, 2011, at 1:23 AM, Matthieu Wipliez wrote:
hi :)

> I have been using the early adopter version for 9 months now, and tried the beta version yesterday.
> With my templates this version is definitely faster!

yeha!!!

> However, I believe I have found a bug in this release with "elseif" conditionally-included templates.
> The test case below fails with "fail2" but I would expect it to work:
> 
> @Test public void testElseIf2() throws Exception {
>         String template = "<if(x)>fail1<elseif(y)>fail2<elseif(z)>works<else>fail3<endif>";
>         ST st = new ST(template);
>         st.add("z", "2DF3DF");
>         String expected = "works";
>         String result = st.render();
>         assertEquals(expected, result);
>     }

Wow! Yeah, looking at the generated bytecodes, I see that it does not create "works" string in the string table. doh! I was building the incorrect tree but generating code directly from that ;) fixed.

> Other differences I have noticed with the early adopter version is that it seems that $it$ is not propagated *at all* anymore.
> For instance I needed to replace
>   $value : {[$it$]}$ 
> with
>   $value : {v | [$v$]}$
> 
> Is this intended?

I decided to get rid of "it" since it can only be used within an anonymous template. you might as well to find the variable you want.

> You mention in the differences between v3 and v4 both "no "it" iteration value" and "default attr 'it' only set if no arg in {...}.".
> So... which one is it? Is "it" allowed?

I need to go update that differences list ;) there is no "it"

> Also, I have tried the TestCoreBasics unit test, and on Windows a couple of tests fail (namely testInclude and testFalseCondWithFormalArgs) because of the difference between the Unix and Windows EOL convention: expected is "x\ny" and result is "x\r\ny".

 thanks. fixed.

Ter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.antlr.org/pipermail/stringtemplate-interest/attachments/20110122/59c01e82/attachment.html 


More information about the stringtemplate-interest mailing list