always evaluate block.super even if it is not used
This commit is contained in:
committed by
David Jennes
parent
a6d0428036
commit
701221c0fb
@@ -320,7 +320,7 @@ final class EnvironmentBaseAndChildTemplateTests: XCTestCase {
|
||||
baseTemplate = try environment.loadTemplate(name: "invalid-base.html")
|
||||
|
||||
try expectError(reason: "filter error",
|
||||
childToken: "block.super",
|
||||
childToken: "extends \"invalid-base.html\"",
|
||||
baseToken: "target|unknown")
|
||||
}
|
||||
|
||||
|
||||
@@ -32,5 +32,24 @@ final class InheritanceTests: XCTestCase {
|
||||
Child_Body
|
||||
"""
|
||||
}
|
||||
|
||||
it("can render block.super in if tag") {
|
||||
let template = try self.environment.loadTemplate(name: "if-block-child.html")
|
||||
|
||||
try expect(try template.render(["sort": "new"])) == """
|
||||
Title - Nieuwste spellen
|
||||
|
||||
"""
|
||||
|
||||
try expect(try template.render(["sort": "upcoming"])) == """
|
||||
Title - Binnenkort op de agenda
|
||||
|
||||
"""
|
||||
|
||||
try expect(try template.render(["sort": "near-me"])) == """
|
||||
Title - In mijn buurt
|
||||
|
||||
"""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
2
Tests/StencilTests/fixtures/if-block-child.html
Normal file
2
Tests/StencilTests/fixtures/if-block-child.html
Normal file
@@ -0,0 +1,2 @@
|
||||
{% extends "if-block.html" %}
|
||||
{% block title %}{% if sort == "new" %}{{ block.super }} - Nieuwste spellen{% elif sort == "upcoming" %}{{ block.super }} - Binnenkort op de agenda{% elif sort == "near-me" %}{{ block.super }} - In mijn buurt{% endif %}{% endblock %}
|
||||
1
Tests/StencilTests/fixtures/if-block.html
Normal file
1
Tests/StencilTests/fixtures/if-block.html
Normal file
@@ -0,0 +1 @@
|
||||
{% block title %}Title{% endblock %}
|
||||
Reference in New Issue
Block a user