Skip to content
Myr

Merge pull request #851 from ngr/tests_for_raw

Before adoption: this commit came in with the history the project adopted, so no landing records it.

{% raw %} tests and note for documentation

authored by David Lord · committed by GitHub · parents ff65310, 0db3afc · Browse files · 2 files+17 added−0 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+17 added−0 removed

  • tests:+12 added−0 removed
  • other:+5 added−0 removed

2 files+17 added−0 removed

modified:docs/templates.rst+5 added
269 unmodified lines
270 {% endfor %}271 </ul>272 {% endraw %}273274.. admonition:: Note275276 Minus sign at the end of ``{% raw -%}`` tag cleans all the spaces and newlines277 preceding the first character of your raw data.278279280.. _line-statements:281282Line Statements283---------------
1389 unmodified lines
modified:tests/test_lexnparse.py+12 added
65 unmodified lines
66 def test_raw2(self, env):67 tmpl = env.from_string('1 {%- raw -%} 2 {%- endraw -%} 3')68 assert tmpl.render() == '123'6970 def test_raw3(self, env):71 # The second newline after baz exists because it is AFTER the {% raw %} and is ignored.72 env = Environment(lstrip_blocks=True, trim_blocks=True)73 tmpl = env.from_string("bar\n{% raw %}\n {{baz}}2 spaces\n{% endraw %}\nfoo")74 assert tmpl.render(baz='test') == "bar\n\n {{baz}}2 spaces\nfoo"7576 def test_raw4(self, env):77 # The trailing dash of the {% raw -%} cleans both the spaces and newlines up to the first character of data.78 env = Environment(lstrip_blocks=True, trim_blocks=False)79 tmpl = env.from_string("bar\n{%- raw -%}\n\n \n 2 spaces\n space{%- endraw -%}\nfoo")80 assert tmpl.render() == "bar2 spaces\n spacefoo"8182 def test_balancing(self, env):83 env = Environment('{%', '%}', '${', '}')84 tmpl = env.from_string('''{% for item in seq85 %}${{'foo': item}|upper}{% endfor %}''')
567 unmodified lines