mirror of
https://github.com/django-components/django-components.git
synced 2025-08-30 18:57:20 +00:00
Add test for more complex template that uses built-in django filter.
This commit is contained in:
parent
d91f014b4b
commit
701e1e3ac2
2 changed files with 20 additions and 0 deletions
2
tests/templates/filtered_template.html
Normal file
2
tests/templates/filtered_template.html
Normal file
|
@ -0,0 +1,2 @@
|
|||
Var1: <strong>{{ var1 }}</strong>
|
||||
Var2 (uppercased): <strong>{{ var2|upper }}</strong>
|
|
@ -46,3 +46,21 @@ class ComponentRegistryTest(SimpleTestCase):
|
|||
<script type="text/javascript" src="script.js"></script>
|
||||
<script type="text/javascript" src="script2.js"></script>
|
||||
""").strip())
|
||||
|
||||
def test_component_with_filtered_template(self):
|
||||
class FilteredComponent(component.Component):
|
||||
def context(self, var1=None, var2=None):
|
||||
return {
|
||||
"var1": var1,
|
||||
"var2": var2,
|
||||
}
|
||||
|
||||
def template(self, context):
|
||||
return "filtered_template.html"
|
||||
|
||||
comp = FilteredComponent()
|
||||
|
||||
self.assertHTMLEqual(comp.render(var1="test1", var2="test2"), dedent("""
|
||||
Var1: <strong>test1</strong>
|
||||
Var2 (uppercased): <strong>TEST2</strong>
|
||||
""").lstrip())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue