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

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

Closed

Conversation

iamnoah
Copy link
Contributor

@iamnoah 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.

Nice for AMD and avoiding globals. Compatible with standard Mustache/Handlebars semantics.
@iamnoah
Copy link
Contributor Author

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
Copy link
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
Copy link
Contributor

daffl commented Jan 11, 2013

People! Talk to me :)

moschel added a commit that referenced this pull request Jan 29, 2013
…amnoah pull request #214 and adding an additional test for globals
@moschel
Copy link
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
Copy link
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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants