Skip to content

Instantly share code, notes, and snippets.

@jberger
Created October 18, 2012 16:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jberger/3913017 to your computer and use it in GitHub Desktop.
Save jberger/3913017 to your computer and use it in GitHub Desktop.
LaTeX templating using Mojo::Template
#!/usr/bin/env perl
use strict;
use warnings;
use Mojo::Template;
my $mt = Mojo::Template->new(
comment_mark => '%',
line_start => '@',
replace_mark => '@',
tag_start => '{@',
tag_end => '@}',
escape => sub { use TeX::Encode; use Encode; encode 'latex', $_[0] },
);
print $mt->render(<<'END', 'jack & jill');
@ my $name = shift;
\documentclass{article}
\begin{document}
Hello {@== $name @}
\end{document}
END
__END__
\documentclass{article}
\begin{document}
Hello jack \& jill
\end{document}
@briandfoy
Copy link

Thanks, because this is what I'm doing tonight.

@jberger
Copy link
Author

jberger commented Jun 1, 2020

Wow @briandfoy, blast from the past!

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