4

Hey everyone!

I already asked if it's possible to pass some variables through partials in handlebars.js. Here is the question: Passing variables through handlebars partial.

Since there's no solution for that, I built a little workaround which you can see here: Rendering templates within helpers in handlebars.

To get this whole thing working, I need a way to assign values to specific variables within a template using handlebars.

The idea is to do something like this:

// Within a template
{{ var a = { foo: 'bar'}; }}

// And then using it like this
{{myHelper a}}

So, is there a way to assign values within a template so that I can use them for post processing?

UPDATE:

Found a little workaround. I'm now using the approach to render templates using registered helpers and passing the helpers an optional hash. Here's the test spec: https://github.com/wycats/handlebars.js/blob/master/spec/qunit_spec.js#L932-945

Community
  • 1
  • 1
Pascal Precht
  • 8,803
  • 7
  • 41
  • 53

0 Answers0