jonschlinkert / template

Render templates from any engine. Make custom template types, use layouts on pages, partials or any custom template type, custom delimiters, helpers, middleware, routes, loaders, and lots more. Powers Assemble v0.6.0, Verb v0.3.0 and your application.
https://github.com/jonschlinkert
MIT License
52 stars 7 forks source link

Allow hash to be passed via "partial" #29

Closed avr closed 9 years ago

avr commented 9 years ago

In Handlebars 3.0 you can pass parameters to a partial like this:

{{> photo image_size="100x100" class="pull-left" }}

I'd like to use the "partial" helper/keyword like this:

{{ partial "photo" image_size="100x100" class="pull-left" }}

From what I can tell, somewhere along the line in Template, the locals.hash property is getting dropped and not passed into the partial. Maybe it's also in engine-assemble. I think I've asked about mergeContext in another thread - I just can't seem to follow the renderTemplate path. Sorry!

I'm using assemble and would like to assemble.create various partial/layout types and use the keyword so that it's a little more obvious to other users what's going on.

doowb commented 9 years ago

This is possible, but will require some updates to our default helpers (e.g. {{partial}}). We've been refactoring template to make it easier to get templates ("views") and understand how the context is merged and presented in the templates. I think the options.hash will just be another context source that can be handled.

avr commented 9 years ago

Cool - thanks for the reply. I'll keep an eye on the changes here as you guys keep working on it.

As always - thanks for all the work you've done here and with Assemble.

jonschlinkert commented 9 years ago

This is possible, but will require some updates to our default helpers (e.g. {{partial}}).

@doowb seems like it should be possible to just override the built-in helper with a custom partial helper that merges the context however you want. right?

doowb commented 9 years ago

Yeah, you can just override it too.