Get WRAPPER functionality from Template :: Toolkit in text :: Xslate

I have used Template :: Toolkit for my last few Catalyst projects and have a setting that I like that allows a clean separation of my templates. Now I hope to use Text :: Xslate , but I am having problems determining if I can make the same settings or not. Below is what I usually use for Template :: Toolkit.

__PACKAGE__->config({ ... WRAPPER => 'site/wrapper', ... }); 

wrapper

 [% content WRAPPER site/html + site/layout %] 

HTML

 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>[% template.title or site.title %]</title> <style type="text/css"> </style> </head> <body> [% content %] </body> </html> 

location

 <div id="header">[% PROCESS site/header %]</div> <div id="content"> [% content %] </div> <div id="footer">[% PROCESS site/footer %]</div>' 

And then the header and footer have their own content. I like this solution because everything is clearly separated, and I don't break div tags around the content, putting the opening tag in the header and closing in the footer. There seems to be some shell functionality with TTerse syntax, but I'm not sure if this allows me to recreate what I usually do. I also found this answer , which says that you can use the shell in theory, but does not actually give any examples.

+7
source share
1 answer

The WRAPPER directive works a little differently in TTerse than in TT2. This basic syntax works:

 [% WRAPPER "include/layout.tt" WITH title = "Lipsum" %] Magna in et vel: feugait erat augue, ut accumsan wisi hendrerit, eu amet laoreet duis. Duis ex nonummy te lorem blandit et velit tation erat amet elit dignissim. [% END %] 

And this is include/layout.tt ,

 # [% title %] [% content %] ---- Commodo quis magna feugiat ullamcorper, exerci tation ut. 

BLOCK is not supported in TTerse.

The TTerse documentation is actually pretty good and includes many workable examples: https://metacpan.org/pod/Text::Xslate::Syntax::TTerse#Functions-and-filters

+1
source

All Articles