I wanted a way to turn off processing for a block of an ep template...
but I could not find one. e.g.
...
<%= somefoo %>
...
<% ep_off %>
...
<%= my_underscore_tags %>
...
<% ep_on %>
...
back to normal
So instead I made a helper that would just pass through a template
untouched. I'm presenting my method here to get comments on it's sanity
and for others to adopt if it suits there needs also.
use Mojolicious::Lite;
use File::Slurp;
app->renderer->add_handler( '_' => sub {
my ( $r, $c, $output, $options ) = @_;
my $inline = $options->{ inline };
my $name = $r->template_name( $options );
my $content = $r->get_data_template( $options, $name );
my $path = $r->template_path( $options );
$$output = read_file($path); # File::Slurp used for example simplicity
return 1;
} );
Then in my ep templates:
%= include '_/myFoo', handler => '_'
Then I put my underscore.js template in 'templates/myFoo.html._' with
it's normal syntax.
It's was also handy putting:
au BufRead,BufNewFile *.html._ set filetype=html.epl
in my .vim/ftdetect/epl.vim file to take advantage of syntax
highlighting for the commonality in their syntax.
Feedback much appreciated,
Wes
Underscore.js shares the same tag syntax for templates as the default
for ep. i.e. <%= tagfoo %>I wanted a way to turn off processing for a block of an ep template...
but I could not find one. e.g....
<%= somefoo %>
...
<% ep_off %>
...
<%= my_underscore_tags %>
...
<% ep_on %>
...
back to normal