Comment #8 on issue 22 by nadir.seen.fire: JavaScript JSONTemplate cannot
be prototyped
http://code.google.com/p/json-template/issues/detail?id=22
Ok the test is alright. Though just for sanity's sake you might want to
test it with
both new ... and without the new, to make sure that use with and without
the new is
consistent. After all the current thing to do is use it without the new.
For a pattern for overriding methods without mutating globals, yes it is
unfortunate
but that isn't something that really exists as a standard in JavaScript.
Normally
either you MonkeyPatch the global, or you just create your own local
function.
If you want, you can make that idiom easier to do with something like this
in the
json-template.js file:
Template.newTemplateClass = function() {
var Template = this;
function JSONTemplate(template_str, options) {
if(!(this instanceof Template))
return new JSONTemplate(template_str, options);
Template.call(this, template_str, options);
}
JSONTemplate.prototype = new Template;
JSONTemplate.newTemplateClass = this.newTemplateClass;
return JSONTemplate;
};
Then someone would just do:
var MyTemplate = jsontemplate.Template.newTemplateClass();
MyTemplate.prototype.myOwnMethod = function() { ... };
var tpl = MyTemplate('...');
tpl.myOwnMethod();
--
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
-~----------~----~----~----~------~----~------~--~---