aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_template.py
diff options
context:
space:
mode:
authorHuayi Zhang <irachex@gmail.com>2016-11-08 17:20:03 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2016-11-08 17:35:26 -0500
commit45bef5d91ddfb7709438ecf89b78ce295e7d3f90 (patch)
tree801032a70d0c353f89d6e31e42bcde783adcd83d /test/test_template.py
parenta18728101e696b05853e89d8b2fe1b7e825a9302 (diff)
downloadexternal_python_mako-45bef5d91ddfb7709438ecf89b78ce295e7d3f90.tar.gz
external_python_mako-45bef5d91ddfb7709438ecf89b78ce295e7d3f90.tar.bz2
external_python_mako-45bef5d91ddfb7709438ecf89b78ce295e7d3f90.zip
Add include_error_handler parameter.
This works like error_handler but is specific to a template when included in another using the include tag. Change-Id: Ie5506a8cba42c71519c703eacc82050902b9ceba Pull-request: https://bitbucket.org/zzzeek/mako/pull-requests/22
Diffstat (limited to 'test/test_template.py')
-rw-r--r--test/test_template.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/test/test_template.py b/test/test_template.py
index f551230..7f21978 100644
--- a/test/test_template.py
+++ b/test/test_template.py
@@ -613,6 +613,21 @@ class IncludeTest(TemplateTest):
""")
assert flatten_result(lookup.get_template("c").render()) == "bar: calling bar this is a"
+ def test_include_error_handler(self):
+ def handle(context, error):
+ context.write('include error')
+ return True
+
+ lookup = TemplateLookup(include_error_handler=handle)
+ lookup.put_string("a", """
+ this is a.
+ <%include file="b"/>
+ """)
+ lookup.put_string("b", """
+ this is b ${1/0} end.
+ """)
+ assert flatten_result(lookup.get_template("a").render()) == "this is a. this is b include error"
+
class UndefinedVarsTest(TemplateTest):
def test_undefined(self):
t = Template("""