Skip to content

Instantly share code, notes, and snippets.

@showyou
Created May 23, 2009 01:15
Show Gist options
  • Save showyou/116454 to your computer and use it in GitHub Desktop.
Save showyou/116454 to your computer and use it in GitHub Desktop.
>>> from mako.template import Template
>>> mytemplate = Template(filename="main.mako")
>>> ms = { "messages": [ {"name":"hoge","content":"foo"}]}
>>> ms
{'messages': [{'content': 'foo', 'name': 'hoge'}]}
>>> print mytemplate.render(**ms)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 //EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<title>Sample HTML</title>
</head>
<body>
<h1>Sample</h1>
<hr />
<div class="content">
<div class ="message">
<span class="message_header">hoge</span>
<span class="message_body">foo</span>
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment