Skip to content

Conversation

pkuras
Copy link

@pkuras pkuras commented Jun 4, 2014

jQuery Mustache plugin was missing support for partial objects which are supported by Mustache. From Mustache docs:

In mustache.js an object of partials may be passed as the third argument to Mustache.render. The object should be keyed by the name of the partial, and its value should be the partial text.

Mustache.render(template, view, {
  user: userTemplate
});

The patch adds support for such object. This allows to choose partial templates dynamically. For example, if template has partial with name {{> content}}, it is now possible to render some differently named template in place of this partial.

Here's an usage example:

        <script type="text/html" id="div">
            <div>
            Div content:
            {{> content}}
            </div>
        </script>
        <script type="text/html" id="content1">
            Hello world!
        </script>
        <script type="text/html" id="content2">
            Bye world!
        </script>
    $('body').mustache('div', {}, {}, {content: 'content1'});
    $('body').mustache('div', {}, {}, {content: 'content2'});

And the result:

Div content: Hello world!
Div content: Bye world!

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.

1 participant