Skip to content

Conversation

bennycode
Copy link

Added "getTemplate" to use this cool jQuery extension with Hogan.JS.

Example:

  $.Mustache.load('./templates.htm').done(function() {
    var template = $.Mustache.getTemplate('plaintext');
    var compiledTemplate = Hogan.compile(template);
    var renderedTemplate = compiledTemplate.render();

    console.log(renderedTemplate);
  });

Added "getTemplate" to use this cool jQuery extension with Hogan.JS.

Example:

      $.Mustache.load('./templates.htm').done(function() {
        var template = $.Mustache.getTemplate('plaintext');
        var compiledTemplate = Hogan.compile(template);
        var renderedTemplate = compiledTemplate.render();
        
        console.log(renderedTemplate);
      });
@jonnyreeves
Copy link
Owner

Hi @bennyn, thanks for the Pull Request.

I am hesitant to add additional methods to the API, especially a getTemplate method as I fear it will make this plugin easier to misuse or misunderstand.

I am however interested in being able to support alternative templating engines; in the 0.3-dev branch I have started looking at how the templating engine (Mustache.js) could be extracted to allow alternative engines (like Hogan) to be used.

I will see if I can put some extra time into these ideas, and hopefully this will meet your particular use case.

Please let me know if you feel there's a compelling reason for adding getTemplate and thanks again for your contribution.

Jonny.

@jonnyreeves
Copy link
Owner

In the mean-time, you can access a template via $.Mustache.templates()[templateName], note that this returns a new copy of the Array each time, so is not the most efficient way of doing things.'

... sorry, scratch that, templates() just returns an Array of template names (:

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.

2 participants