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

Question. Use global functions in interpolation or js mode #257

Open
jaimegarza opened this issue Jul 18, 2023 · 1 comment
Open

Question. Use global functions in interpolation or js mode #257

jaimegarza opened this issue Jul 18, 2023 · 1 comment

Comments

@jaimegarza
Copy link

I have the need to declare global functions that I want to make available in the curly braces, like this

function md5(str) {
    return "as23sfgo94kl9sde445asdfloremipsumdolor"; // fake of course
}

Then {{md5(it.description)} or {{! md5(it.description)}

I get told that md5 is not defined. This is just a sample of what I am trying to do. Any guidance of how to make globals available, including functions? I know that I can do it as a filter, but I have the need for other things, like {{weekadd(it.someDate, 2)}} etc

@nebrelbug
Copy link
Collaborator

I'd probably recommend using filters, defining a helper, or passing the function in through it.

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