Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # main.py
- import os
- import jinja2
- TEMPLATE_FILENAME = 'index.html'
- TEMPLATE_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'templates')
- env = jinja2.Environment(loader=jinja2.FileSystemLoader(TEMPLATE_DIR))
- template = env.get_template(TEMPLATE_FILENAME)
- text = template.render()
- lineno =template.get_corresponding_lineno(1)
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Title</title>
- </head>
- <body>
- {% if 2 + 2 == 4 %}
- <p>This looks ok</p>
- {% else %}
- <p>This is not good</p>
- {% endif %}
- </body>
- </html>
- Traceback (most recent call last):
- File "/Users/nikolaygolub/workspace/my/coverage-jinja-plugin/example/run.py", line 15, in <module>
- print(template.get_corresponding_lineno(8))
- File "/Users/nikolaygolub/workspace/pyenvs/py3all/lib/python3.5/site-packages/jinja2/environment.py", line 1056, in get_corresponding_lineno
- for template_line, code_line in reversed(self.debug_info):
- File "/Users/nikolaygolub/workspace/pyenvs/py3all/lib/python3.5/site-packages/jinja2/environment.py", line 1072, in debug_info
- self._debug_info.split('&')]
- File "/Users/nikolaygolub/workspace/pyenvs/py3all/lib/python3.5/site-packages/jinja2/environment.py", line 1071, in <listcomp>
- return [tuple(imap(int, x.split('='))) for x in
- ValueError: invalid literal for int() with base 10: ''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement