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

variable helper #64

Open
ray73864 opened this issue Aug 7, 2019 · 1 comment
Open

variable helper #64

ray73864 opened this issue Aug 7, 2019 · 1 comment

Comments

@ray73864
Copy link

ray73864 commented Aug 7, 2019

Is it possible to have a 'variable' type helper?

With Handlebars (which a lot of my old stuff uses) I have a helper called 'var', this helper is defined as

Handlebars.registerHelper('var', function(name, value, context) { this[name] = value; });

Then in code I would do

{{var myVariable "Test"}}

Then I could access that variable by doing

{{myVariable}}

Is there any way to do something similar with Template7?

@ray73864
Copy link
Author

ray73864 commented Aug 7, 2019

Actually, looking at it further, it does work, but not with anything more complex.

So as above it works fine, but if I do

{{ var "myVariable" ( myHelper "test" ) }}

Where 'myHelper' might be defined as

Template7.registerHelper('myHelper', function(val) { return val; });

And then I later on call that variable by doing

{{myVariable}}

Template7 comes back with a

Uncaught SyntaxError: Unexpected token (
    at Template7Class.compile (template7.js:600)
    at Function.Template7.compile (template7.js:649)

This is using Template7 1.4.1, i've also tried 1.3.6 (which is what I was using earlier)

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

1 participant