Advertisement
Guest User

Untitled

a guest
May 4th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. # main.py
  2. import os
  3. import jinja2
  4.  
  5. TEMPLATE_FILENAME = 'index.html'
  6. TEMPLATE_DIR = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'templates')
  7.  
  8. env = jinja2.Environment(loader=jinja2.FileSystemLoader(TEMPLATE_DIR))
  9.  
  10. template = env.get_template(TEMPLATE_FILENAME)
  11. text = template.render()
  12. lineno =template.get_corresponding_lineno(1)
  13.  
  14. <!DOCTYPE html>
  15. <html lang="en">
  16. <head>
  17. <meta charset="UTF-8">
  18. <title>Title</title>
  19. </head>
  20. <body>
  21. {% if 2 + 2 == 4 %}
  22. <p>This looks ok</p>
  23. {% else %}
  24. <p>This is not good</p>
  25. {% endif %}
  26. </body>
  27. </html>
  28.  
  29. Traceback (most recent call last):
  30. File "/Users/nikolaygolub/workspace/my/coverage-jinja-plugin/example/run.py", line 15, in <module>
  31. print(template.get_corresponding_lineno(8))
  32. File "/Users/nikolaygolub/workspace/pyenvs/py3all/lib/python3.5/site-packages/jinja2/environment.py", line 1056, in get_corresponding_lineno
  33. for template_line, code_line in reversed(self.debug_info):
  34. File "/Users/nikolaygolub/workspace/pyenvs/py3all/lib/python3.5/site-packages/jinja2/environment.py", line 1072, in debug_info
  35. self._debug_info.split('&')]
  36. File "/Users/nikolaygolub/workspace/pyenvs/py3all/lib/python3.5/site-packages/jinja2/environment.py", line 1071, in <listcomp>
  37. return [tuple(imap(int, x.split('='))) for x in
  38. ValueError: invalid literal for int() with base 10: ''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement