-->

xslate/Catalyst::View::Xslate wrapper

2019-07-16 13:53发布

问题:

I have a Catalyst application that uses TT for views: https://metacpan.org/module/Catalyst::View::TT

and I would like to try out https://metacpan.org/module/Catalyst::View::Xslate

We use the WRAPPER directive with Template Toolkit and I am curious if it is at all possible to reuse the wrapper somehow with xslate or would I have to break them into headers and footers?

回答1:

You can in theory, by using TTerse syntax. According to the manual, enabling this allows you to use a lot of TT compatible code, including a simple WRAPPER statement.

However, there are caveats, as documented here. Given the philosophical differences between Xslate and TT, you might find it easier to bite the bullet and just rewrite your wrapper as header and footer Xslate code.

Or hold off on Xslate until your next project. Like horses, Templating engines are difficult to change mid-stream. :-)