diff --git a/Project.toml b/Project.toml index ef318c0..b169534 100644 --- a/Project.toml +++ b/Project.toml @@ -8,7 +8,8 @@ Tables = "bd369af6-aec1-5ad0-b16a-f7cc5008161c" [compat] Tables = "1" -julia = "1.0" +Printf = "1.6" +julia = "1.6" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/src/tokens.jl b/src/tokens.jl index bc07edc..573cacc 100644 --- a/src/tokens.jl +++ b/src/tokens.jl @@ -530,7 +530,8 @@ function _renderTokensByValue(value::Function, io, token, writer, context, templ ## Supposed to be called value(sec_value, render+context) but ## we call render(value(sec_value), context) push_task_local_storage(view) - _render = x -> render(x, view) + tags = (token.ltag, token.rtag) + _render = x -> render(parse(x, tags), view) out = try value(sec_value, _render) catch err diff --git a/test/Mustache_test.jl b/test/Mustache_test.jl index 676bcdb..0926a19 100644 --- a/test/Mustache_test.jl +++ b/test/Mustache_test.jl @@ -306,4 +306,24 @@ tpl2 = mt""" ## Issue #143 look up key before checking for dotted @test render("Hello, {{ values.name }}!", Dict("values.name"=>"world")) == "Hello, world!" + + ## Issue 156 function calls with other tags + tpla = """ +<<#:vec>> +- <<{name}>> +- <<#:uppercase>><<{name}>><> +<> +""" + tplb = """ +{{#:vec}} +- {{{name}}} +- {{#:uppercase}}{{{name}}}{{/:uppercase}} +{{/:vec}} +""" + view = [Dict("name" => x) for x in ("a", "b")] + _uppercase(str, render) = uppercase(render(str)) + a = Mustache.render(Mustache.parse(tpla, ("<<", ">>")); vec, uppercase=_uppercase) + b = Mustache.render(Mustache.parse(tplb); vec, uppercase=_uppercase) + @test a == b + end