Pass parameter to snippet
arlopezg opened this issue · 1 comments
arlopezg commented
Hi everybody!
Currently I'm having an issue while trying to pass a parameter to a function inside a snippet from another file. I'm running the latest version of doT. This is a small example of what I'm doing:
Snippet that declares the function and param:
<!-- snippet.def -->
{{## def.testFn = function (anything) {
console.log(anything);
}}
This is the template that calls the snippet and its function:
<!-- template.def -->
{{#def.snippet}}
{{ some_variable = {"foo": "bar"}; }}
{{# def.testFn(some_variable) }} // prints "some_variable" as string instead of `some_variable` actual value
I've also tried {{# def.testFn({{= some_variable}}) }}
but I get a similar result - it just prints {{= some_variable}}
The behavior that I'd expect is being able to pass a runtime variable value to the compiled def.testFn
, instead of its name as string, as shown here@124.