Allow "getTemplateNode" to be 'public' for template plugins extending core plugin #82

Closed
wants to merge 1 commit into
from

Projects

None yet

2 participants

@ifandelse

Steve - I would like to make the "getTemplateNode" function on the "jqueryTmplTemplateEngine" a 'public' member. Here is a hopefully helpful (and convincing :-)) explanation why:

I've written a templating engine plugin for Knockout that extends your original engine, but allows for external templates to be pulled down on-demand from the server so that they don't have to initially exist in the html document when first requested. My templating engine plugin utilizes the same functionality as yours, with the following exceptions:

  • The getTemplateNode function performs the request to pull a template down from the server if it's not already in the DOM
  • Additional 'public' members have been added to configure how the requests will be made to fetch a template

So, I'm effectively adding a handful of members to your original templating engine, and tweaking the behavior of "getTemplateNode" - otherwise, the functionality is identical.

I'm proposing this merge since making the "getTemplateNode" function a 'public' member of the templating engine plugin means that my plugin (and future plugins using jquery templates) can take advantage of the clean functionality of yours simply by invoking "ko.jqueryTmplTemplateEngine.call(this, arguments);" and then extending behavior from there. Following this approach allows any plugins based on your original one to stay in sync with it as it is updated/fixed/enhanced over time.

To see an example of my "externaljQueryTemplateEngine" plugin using this forked version of Knockout.js, please go here.

I've run all the tests after applying my changes to the fork and they pass.

@ifandelse ifandelse Modifying the jQueryTmplTemplateEngine.js file to make getTemplateNod…
…e a 'public' member of the object, so that it's behavior can be swapped out in plugins that call and override this engine plugin.
173cdb6
@rniemeyer
Member

I think that the functionality in your engine would be quite interesting and useful to many people. The changes seem minor to the core. I like it! +1

@ifandelse

Thanks Steve!

@ifandelse ifandelse closed this Apr 20, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment