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

Enabled passing in helpers and partials to Mustache views. #214

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
3 participants
@iamnoah
Contributor

iamnoah commented Dec 17, 2012

Nice for AMD and avoiding globals. Compatible with standard Mustache/Handlebars semantics.

Usage:

    renderer(data,{
      helpers: {
         cap: function(s) { return s.toUpperCase(); }
      },
      partials: {
         partial: anotherRenderer
      }
    });

Partials can be the view function returned by steal, a new can.Mustache, or a plain old function that takes data and returns a string.

Enabled passing in helpers and partials to Mustache views.
Nice for AMD and avoiding globals. Compatible with standard Mustache/Handlebars semantics.
@iamnoah

This comment has been minimized.

Show comment
Hide comment
@iamnoah

iamnoah Dec 17, 2012

Contributor

The Handlebars semantics are:

template(context, {helpers: helpers, partials: partials, data: data})

So this makes the can.Mustache renderers interchangeable with Handlebars functions, which makes migration easier.

Contributor

iamnoah commented Dec 17, 2012

The Handlebars semantics are:

template(context, {helpers: helpers, partials: partials, data: data})

So this makes the can.Mustache renderers interchangeable with Handlebars functions, which makes migration easier.

@daffl

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Jan 3, 2013

Contributor

I think helpers have been added in aeb3448. I do agree however, that it should use handlebars semantics. @moschel Input?

Contributor

daffl commented Jan 3, 2013

I think helpers have been added in aeb3448. I do agree however, that it should use handlebars semantics. @moschel Input?

@ghost ghost assigned moschel Jan 11, 2013

@daffl

This comment has been minimized.

Show comment
Hide comment
@daffl

daffl Jan 11, 2013

Contributor

People! Talk to me :)

Contributor

daffl commented Jan 11, 2013

People! Talk to me :)

moschel added a commit that referenced this pull request Jan 29, 2013

Enabled passing in helpers and partials to Mustache views, merging @i…
…amnoah pull request #214 and adding an additional test for globals
@moschel

This comment has been minimized.

Show comment
Hide comment
@moschel

moschel Jan 29, 2013

Contributor

I like this request for a different reason, the fact that it makes helpers local vs global. The fact that it follows handlebars semantics is icing on the cake and kills 2 birds with one stone. I made the original API work as well (passing helpers in as the optional 3rd argument) for consistency with EJS. I also added another test to prove that this removes the global helpers issue.

Contributor

moschel commented Jan 29, 2013

I like this request for a different reason, the fact that it makes helpers local vs global. The fact that it follows handlebars semantics is icing on the cake and kills 2 birds with one stone. I made the original API work as well (passing helpers in as the optional 3rd argument) for consistency with EJS. I also added another test to prove that this removes the global helpers issue.

@moschel

This comment has been minimized.

Show comment
Hide comment
@moschel

moschel Jan 29, 2013

Contributor

merged with master and added more tests in #260

Contributor

moschel commented Jan 29, 2013

merged with master and added more tests in #260

@moschel moschel closed this Jan 29, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment