Skip to content

Instantly share code, notes, and snippets.

@tusbar
Created November 1, 2014 13:12
Show Gist options
  • Save tusbar/18ae69c38066fd4cfb02 to your computer and use it in GitHub Desktop.
Save tusbar/18ae69c38066fd4cfb02 to your computer and use it in GitHub Desktop.
Mako test
from mako.template import Template
with file('template.html') as foo:
print Template(
foo.read(),
output_encoding='utf-8',
input_encoding='utf-8',
default_filters=['decode.utf8', 'h'],
encoding_errors='replace'
).render()
<%! from markupsafe import escape %>
<p>${('The page that you were looking for was not found.')}
${escape('Go back to the {link_start}home page{link_end} or let us know about any pages that may have been moved at {email}.').format(
link_start='<a href="/">',
link_end='</a>',
email=u'<a href="mailto:{address}">{address}</a>'.format(
address='google.com'
)) | n}
</p>
@tusbar
Copy link
Author

tusbar commented Nov 1, 2014

(mako)$ python --version
Python 2.7.8
(mako)$ pip freeze | grep Mako
Mako==0.9.1
(mako)$ uname
Darwin
(mako)$ python main.py

<p>The page that you were looking for was not found.
  Go back to the &lt;a href=&#34;/&#34;&gt;home page&lt;/a&gt; or let us know about any pages that may have been moved at &lt;a href=&#34;mailto:google.com&#34;&gt;google.com&lt;/a&gt;.
</p>

@tusbar
Copy link
Author

tusbar commented Nov 1, 2014

 edxapp@precise64:~/mako-tests$ python --version
 Python 2.7.3
 edxapp@precise64:~/mako-tests$ pip freeze | grep Mako
 Mako==0.9.1
 edxapp@precise64:~/mako-tests$ uname
 Linux
 edxapp@precise64:~/mako-tests$ python main.py

 <p>The page that you were looking for was not found.
   Go back to the <a href="/">home page</a> or let us know about any pages that may have been moved at <a href="mailto:google.com">google.com</a>.
 </p>

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