Skip to content

Instantly share code, notes, and snippets.

@tempire
Last active December 26, 2015 04:19
Show Gist options
  • Select an option

  • Save tempire/7092381 to your computer and use it in GitHub Desktop.

Select an option

Save tempire/7092381 to your computer and use it in GitHub Desktop.
Load templates from __DATA__ @@Sections with replacement
use Modern::Perl;
use Mojo::Template;
use Mojo::Loader;
say Mojo::Template->new->render(Mojo::Loader->new->data(__PACKAGE__, 'hello'),
qw/ glen hinkle /);
__DATA__
@@ hello
% my ($fname, $lname) = @_;
HELLO <%= $fname %> <%= $lname %>
@phillipadsmith
Copy link

Could one not use https://metacpan.org/pod/Mojo::Util#slurp here also?

@tempire
Copy link
Author

tempire commented Feb 25, 2014

If you were loading from another file, and not concerned about getting only the one @@ section of __DATA__, yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment