diff --git a/hyde/ext/templates/jinja.py b/hyde/ext/templates/jinja.py index e1f0c9f..eacddb1 100644 --- a/hyde/ext/templates/jinja.py +++ b/hyde/ext/templates/jinja.py @@ -465,6 +465,7 @@ class Jinja2Template(Template): self.loader = HydeLoader(self.sitepath, site, self.preprocessor) self.env = Environment(loader=self.loader, undefined=SilentUndefined, + line_statement_prefix='---', trim_blocks=True, bytecode_cache=FileSystemBytecodeCache(), extensions=[IncludeText, diff --git a/hyde/tests/test_jinja2template.py b/hyde/tests/test_jinja2template.py index 8e3354c..1bb2e84 100644 --- a/hyde/tests/test_jinja2template.py +++ b/hyde/tests/test_jinja2template.py @@ -150,6 +150,22 @@ def test_markdown_with_extensions(): assert html == u'

Heading 3

' +def test_line_statements(): + source = """ + ---markdown + ### Heading 3 + + --- endmarkdown + """ + t = Jinja2Template(JINJA2.path) + s = Site(JINJA2.path) + c = Config(JINJA2.path, config_dict=dict(markdown=dict(extensions=['headerid']))) + s.config = c + t.configure(s) + html = t.render(source, {}).strip() + assert html == u'

Heading 3

' + + TEST_SITE = File(__file__).parent.child_folder('_test') @nottest @@ -163,7 +179,6 @@ def assert_markdown_typogrify_processed_well(include_text, includer_text): gen.load_template_if_needed() template = gen.template html = template.render(includer_text, {}).strip() - print html assert html q = PyQuery(html) assert "is_processable" not in html @@ -207,6 +222,29 @@ class TestJinjaTemplate(object): assert 'layout.html' in deps assert 'index.html' in deps + def test_line_statements_with_blocks(self): + site = Site(TEST_SITE) + JINJA2.copy_contents_to(site.content.source) + inc = File(TEST_SITE.child('content/inc.md')) + text = """ + {% extends 'index.html' %} + --- block body +
Heya
+ --- endblock + """ + site.load() + gen = Generator(site) + gen.load_template_if_needed() + template = gen.template + html = template.render(text, {}).strip() + + assert html + q = PyQuery(html) + article = q("#article") + assert article.length == 1 + assert article.text() == "Heya" + + def test_depends_with_reference_tag(self): site = Site(TEST_SITE) JINJA2.copy_contents_to(site.content.source)