xslate / p5-Text-Xslate

Scalable template engine for Perl5
https://metacpan.org/release/Text-Xslate
Other
121 stars 47 forks source link

TTerse [% WRAPPER %] ignores content before and after #134

Closed bluefeet closed 10 years ago

bluefeet commented 10 years ago

A template like this:

Foo
[% WRAPPER 'foo.tt' %]
Baz
[% END %]
Bar

Does not render "Foo" and "Bar" strings and actually produces these warnings:

Xslate: Useless use of text 'Foo' at /usr/local/lib/perl/5.14.2/Text/Xslate/Compiler.pm line 495.
Xslate: Useless use of text 'Bar' at /usr/local/lib/perl/5.14.2/Text/Xslate/Compiler.pm line 495.

In vanilla-TT I'm able to render content before and after wrappers, and can even include multiple wrappers in the same document. Seems TTerse doesn't allow this, which greatly diminishes TTerse as a useful syntax for transitioning an existing TT site to Xslate. Any ideas?

bluefeet commented 10 years ago

I've worked around this issue using MACRO. So the above sample works as:

Foo
[% MACRO foo BLOCK %]
Baz
[% END -%]
[% INCLUDE 'foo.tt' WITH content => foo() %]
Bar

I think that properly simulates TT wrappers, at least it appears so.

Maybe the fix is to just document this workaround?

gfx commented 10 years ago

As you has pointed at, WRAPPER is not completely compatible with TT. Using MACRO is the best solution for it. Thanks.