You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
2.0 KiB

7 months ago
  1. <!doctype html>
  2. <title>CodeMirror: Jinja2 mode</title>
  3. <meta charset="utf-8"/>
  4. <link rel=stylesheet href="../../doc/docs.css">
  5. <link rel="stylesheet" href="../../lib/codemirror.css">
  6. <script src="../../lib/codemirror.js"></script>
  7. <script src="jinja2.js"></script>
  8. <style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
  9. <div id=nav>
  10. <a href="https://codemirror.net/5"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a>
  11. <ul>
  12. <li><a href="../../index.html">Home</a>
  13. <li><a href="../../doc/manual.html">Manual</a>
  14. <li><a href="https://github.com/codemirror/codemirror5">Code</a>
  15. </ul>
  16. <ul>
  17. <li><a href="../index.html">Language modes</a>
  18. <li><a class=active href="#">Jinja2</a>
  19. </ul>
  20. </div>
  21. <article>
  22. <h2>Jinja2 mode</h2>
  23. <form><textarea id="code" name="code">
  24. {# this is a comment #}
  25. {%- for item in li -%}
  26. &lt;li&gt;{{ item.label }}&lt;/li&gt;
  27. {% endfor -%}
  28. {{ item.sand == true and item.keyword == false ? 1 : 0 }}
  29. {{ app.get(55, 1.2, true) }}
  30. {% if app.get(&#39;_route&#39;) == (&#39;_home&#39;) %}home{% endif %}
  31. {% if app.session.flashbag.has(&#39;message&#39;) %}
  32. {% for message in app.session.flashbag.get(&#39;message&#39;) %}
  33. {{ message.content }}
  34. {% endfor %}
  35. {% endif %}
  36. {{ path(&#39;_home&#39;, {&#39;section&#39;: app.request.get(&#39;section&#39;)}) }}
  37. {{ path(&#39;_home&#39;, {
  38. &#39;section&#39;: app.request.get(&#39;section&#39;),
  39. &#39;boolean&#39;: true,
  40. &#39;number&#39;: 55.33
  41. })
  42. }}
  43. {% include (&#39;test.incl.html.twig&#39;) %}
  44. # for item in seq:
  45. &lt;li&gt;{{ item }} &lt;/li&gt; ## this comment is ignored
  46. # endfor
  47. # set text = "Multiline
  48. text"
  49. # for href, caption in [('index.html', 'Index'),
  50. ('about.html', 'About')]:
  51. &lt;li&gt;&lt;a href="{{ href }}"&gt;{{ caption }}&lt;/a&gt;&lt;/li&gt;
  52. # endfor
  53. </textarea></form>
  54. <script>
  55. var editor =
  56. CodeMirror.fromTextArea(document.getElementById("code"), {mode:
  57. {name: "jinja2", htmlMode: true}});
  58. </script>
  59. </article>