Skip to content

Instantly share code, notes, and snippets.

@brun0xff
Created June 6, 2017 20:32
Show Gist options
  • Save brun0xff/f32f2ff359bb89ae43bdf7ece99229fb to your computer and use it in GitHub Desktop.
Save brun0xff/f32f2ff359bb89ae43bdf7ece99229fb to your computer and use it in GitHub Desktop.
from mako.template import Template
from mako.runtime import Context
tpl_xml = '''
<doc>
% for i in data:
<p>${i}</p>
% endfor
</doc>
'''
tpl = Template(tpl_xml)
with open('output.xml', 'w') as f:
ctx = Context(f, data=xrange(100))
tpl.render_context(ctx)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment