@@ -265,7 +265,13 @@ class Refer(Extension): | |||||
includeNode.ignore_missing = False | includeNode.ignore_missing = False | ||||
includeNode.template = template | includeNode.template = template | ||||
temp = parser.free_identifier(lineno) | |||||
return [ | return [ | ||||
nodes.Assign( | |||||
nodes.Name(temp.name, 'store'), | |||||
nodes.Name(MARKINGS, 'load') | |||||
).set_lineno(lineno), | |||||
nodes.Assign( | nodes.Assign( | ||||
nodes.Name(MARKINGS, 'store'), | nodes.Name(MARKINGS, 'store'), | ||||
nodes.Const({})).set_lineno(lineno), | nodes.Const({})).set_lineno(lineno), | ||||
@@ -295,6 +301,10 @@ class Refer(Extension): | |||||
nodes.Getitem(nodes.Name(namespace, 'load'), | nodes.Getitem(nodes.Name(namespace, 'load'), | ||||
nodes.Const('parent_resource'), 'load') | nodes.Const('parent_resource'), 'load') | ||||
).set_lineno(lineno), | ).set_lineno(lineno), | ||||
nodes.Assign( | |||||
nodes.Name(MARKINGS, 'store'), | |||||
nodes.Name(temp.name, 'load') | |||||
).set_lineno(lineno), | |||||
] | ] | ||||
def _push_resource(self, namespace, site, resource, template, caller): | def _push_resource(self, namespace, site, resource, template, caller): | ||||
@@ -128,6 +128,7 @@ def assert_markdown_typogrify_processed_well(include_text, includer_text): | |||||
gen.load_template_if_needed() | gen.load_template_if_needed() | ||||
template = gen.template | template = gen.template | ||||
html = template.render(includer_text, {}).strip() | html = template.render(includer_text, {}).strip() | ||||
print html | |||||
assert html | assert html | ||||
q = PyQuery(html) | q = PyQuery(html) | ||||
assert "is_processable" not in html | assert "is_processable" not in html | ||||
@@ -200,7 +201,7 @@ class TestJinjaTemplate(object): | |||||
deps = list(t.get_dependencies('inc.md')) | deps = list(t.get_dependencies('inc.md')) | ||||
assert len(deps) == 1 | assert len(deps) == 1 | ||||
assert not deps[0] | assert not deps[0] | ||||
@@ -314,6 +315,52 @@ Hyde & Jinja. | |||||
assert "mark" not in html | assert "mark" not in html | ||||
assert "reference" not in html | assert "reference" not in html | ||||
def test_two_level_refer_with_var(self): | |||||
text = """ | |||||
=== | |||||
is_processable: False | |||||
=== | |||||
<div class="fulltext"> | |||||
{% filter markdown|typogrify %} | |||||
{% mark heading %} | |||||
This is a heading | |||||
================= | |||||
{% endmark %} | |||||
{% reference content %} | |||||
Hyde & Jinja. | |||||
{% endreference %} | |||||
{% endfilter %} | |||||
</div> | |||||
""" | |||||
text2 = """ | |||||
{% set super = 'super.md' %} | |||||
{% refer to super as sup %} | |||||
<div class="justhead"> | |||||
{% mark child %} | |||||
{{ sup.heading }} | |||||
{% endmark %} | |||||
{% mark cont %} | |||||
{{ sup.content }} | |||||
{% endmark %} | |||||
</div> | |||||
""" | |||||
text3 = """ | |||||
{% set incu = 'inc.md' %} | |||||
{% refer to incu as inc %} | |||||
{% filter markdown|typogrify %} | |||||
{{ inc.child }} | |||||
{{ inc.cont }} | |||||
{% endfilter %} | |||||
""" | |||||
superinc = File(TEST_SITE.child('content/super.md')) | |||||
superinc.write(text) | |||||
html = assert_markdown_typogrify_processed_well(text2, text3) | |||||
assert "mark" not in html | |||||
assert "reference" not in html | |||||
def test_refer_with_var(self): | def test_refer_with_var(self): | ||||
text = """ | text = """ | ||||