Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pass parameter to snippet #304

Closed
arlopezg opened this issue Mar 2, 2021 · 1 comment
Closed

Pass parameter to snippet #304

arlopezg opened this issue Mar 2, 2021 · 1 comment

Comments

@arlopezg
Copy link

arlopezg commented Mar 2, 2021

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.

@udamir
Copy link

udamir commented Aug 28, 2022

Hi, try my fork xdot, I have added support for parameter to a function inside a snippet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants