Created
October 18, 2012 16:30
-
-
Save jberger/3913017 to your computer and use it in GitHub Desktop.
LaTeX templating using Mojo::Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks, because this is what I'm doing tonight.