Comment #6 on issue 22 by nadir.seen.fire: JavaScript JSONTemplate cannot
be prototyped
http://code.google.com/p/json-template/issues/detail?id=22
I'm just saying to support prototyping the template like any other
JavaScript class.
It's up to people whether or not they want to prototype or just create local
functions of their own.
For those wanting to inherit, something like this should theoretically work:
var JSONTemplate = (function(jsontemplate) {
function JSONTemplate(template_str, options) {
if(!(this instanceof jsontemplate.Template))
return new JSONTemplate(template_str, options);
jsontemplate.Template.call(this, template_str, options);
}
JSONTemplate.prototype = new jsontemplate.Template;
return JSONTemplate;
})(jsontemplate);
The wrapping function just makes sure that nothing breaks if someone
decides to
change the global jsontemplate variable to something else.
It's just the common trick of using a call/apply on a constructor passing
this to it,
plus the same bit I noted for the actual jsontemplate to make the function
work
without the new keyword.
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "JSON
Template" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/json-template?hl=en
-~----------~----~----~----~------~----~------~--~---