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

feature request: inline partial definitions #792

Closed
ashanbrown opened this issue May 2, 2014 · 2 comments
Closed

feature request: inline partial definitions #792

ashanbrown opened this issue May 2, 2014 · 2 comments
Labels
Milestone

Comments

@ashanbrown
Copy link

There was some discussion on inline partial definitions and mustache/spec#63 but it looks like it went off the rails a bit.

I'm addicted to 'capture' in the erb/haml world. It seems to me that combined with subexpressions, you could use inline partial definition to pass the outputs of multiple blocks to a view or helper. Using one of the proposed partial definitions from @spudly, you'd be able to write code like this:

{{>> bold-name}}
  <strong>{{name}}</strong>
{{/>>}}
{{#tooltip title:(bold-name)}}
  My name is bold.
{{/tooltip}}

Maybe partials could even accept arguments. Sorry if I've got to wrong forum for this and if there is some better existing solution that I haven't stumbled across. I think that the general push on the mustache site discussion was to define such helpers outside the template. I didn't quite follow all the reasons given to oppose this idea, but given how convenient I find 'capture' in rails, I'd love for handlebars to offer the same convenience.

Thanks for your consideration. If there's interest in this, I might investigate a pull request for this.

@kpdecker kpdecker added this to the Backlog milestone Jul 5, 2014
@difosfor
Copy link

difosfor commented Sep 3, 2014

FYI: I'm currently using this technique:

Handlebars.registerHelper('partial', function(name, options) {
    Handlebars.registerPartial(name, options.fn);
});

See also: Issue #857

@kpdecker
Copy link
Collaborator

kpdecker commented May 5, 2015

The proposal in #1018 will allow for this:

{{*bold-name}}
  <strong>{{$default}}</strong>
{{/bold-name}}

{{#bold-name}}
  My name is bold.
{{/bold-name}}
{{#bold-name}}
  So is mine.
{{/bold-name}}

Closing this in favor of #1018 and requesting comments there.

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

No branches or pull requests

3 participants