Skip to content

Commit

Permalink
Updated mixin function names. Return template object when registering.
Browse files Browse the repository at this point in the history
  • Loading branch information
eneko committed Mar 25, 2010
1 parent c7e497a commit 0b54c48
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions Source/mooml.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -184,20 +184,21 @@ Mooml.Templates = {
templates: {}, templates: {},


/** /**
* Registers a new template for later use * Registers a new template for later use or returns an existing template with that name
* @param {String} name The name of the template * @param {String} name The name of the template
* @param {Function} code The code function of the template * @param {Function} code The code function of the template
*/ */
register: function(name, code, options) { registerTemplate: function(name, code, options) {
this.templates[name] = new Mooml.Template(name, code, options); var template = this.templates[name];
return (template)? template : new Mooml.Template(name, code, options);
}, },


/** /**
* Evaluates a registered template * Evaluates a registered template or returns null if template not registered
* @param {String} name The name of the template to evaluate * @param {String} name The name of the template to evaluate
* @param {Object|Array} data Optional data object or array of objects * @param {Object|Array} data Optional data object or array of objects
*/ */
render: function(name, data) { renderTemplate: function(name, data) {
var template = this.templates[name]; var template = this.templates[name];
return (template)? template.render(data) : null; return (template)? template.render(data) : null;
} }
Expand All @@ -206,9 +207,10 @@ Mooml.Templates = {




/** /**
* Implement Mooml.Templates into Mooml * Implement Mooml.Templates into Mooml and alias for backwards compatibility
*/ */
$extend(Mooml, Mooml.Templates); $extend(Mooml, Mooml.Templates);

Mooml.register = Mooml.registerTemplate;
Mooml.render = Mooml.renderTemplate;


Mooml.initEngine(); Mooml.initEngine();

0 comments on commit 0b54c48

Please sign in to comment.