Skip to content

Instantly share code, notes, and snippets.

@offby1
Forked from anonymous/jinja.tmp
Last active October 28, 2015 21:05
Show Gist options
  • Save offby1/4a26b298d77a381f90e2 to your computer and use it in GitHub Desktop.
Save offby1/4a26b298d77a381f90e2 to your computer and use it in GitHub Desktop.
%{ for count in range(0, multis) -%}
%{{ count %}} & A & B & C & D\\ \hline
%{ set count = count + 1 -%}
%{ endfor -%}
%{{ multis %}} & X & X & X & X\\ \hline
import jinja2
import os
report_renderer = jinja2.Environment(
block_start_string = '%{',
block_end_string = '%}',
variable_start_string = '%{{',
variable_end_string = '%}}',
loader = jinja2.FileSystemLoader(os.path.abspath('.'))
)
with open('jinja.tmp') as inf:
print(report_renderer.from_string(inf.read()).render( multis = 10))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment