Permalink
Browse files

adding support for <code> tag

  • Loading branch information...
1 parent bfab905 commit 762a7b8cc0f3faa0f6f46c768d3ce757b499a41e @ahmadnassri ahmadnassri committed Jan 30, 2013
Showing with 15 additions and 15 deletions.
  1. +15 −15 Source/mooml.js
View
@@ -60,9 +60,9 @@ var Mooml = {
"ul",
"var", "video",
// Deprecated in HTML 5
- "acronym", "applet", "basefont", "big", "center", "dir", "font", "frame", "frameset", "noframes", "s", "strike", "tt", "u", "xmp"
+ "acronym", "applet", "basefont", "big", "center", "dir", "font", "frame", "frameset", "noframes", "s", "strike", "tt", "u", "xmp",
// Not supported tags
- // "code"
+ "code"
],
/**
@@ -76,15 +76,15 @@ var Mooml = {
this.engine.callstack.push(template);
if (template.prepared == false) {
- template.code = this.prepare(template.code);
+ template.HTMLCode = this.prepare(template.HTMLCode);
template.prepared = true;
}
Array.from([data, {}].pick()).each(function(params, index) {
if (bind) {
- template.code.apply(bind, [params, index]);
+ template.HTMLCode.apply(bind, [params, index]);
} else {
- template.code(params, index);
+ template.HTMLCode(params, index);
}
elements.append(template.nodes.filter(function(node) {
@@ -173,12 +173,12 @@ var Mooml = {
/**
* Prepares a template function so it can be called directly without using eval
- * @param {Function} code The template function to prepare
+ * @param {Function} HTMLCode The template function to prepare
*/
- prepare: function(code) {
- var codeStr = code.toString();
- var args = codeStr.match(/\(([a-zA-Z0-9,\s]*)\)/)[1].replace(/\s/g, '').split(',');
- var body = codeStr.match(/\{([\s\S]*)\}/m)[1];
+ prepare: function(HTMLCode) {
+ var HTMLCodeStr = HTMLCode.toString();
+ var args = HTMLCodeStr.match(/\(([a-zA-Z0-9,\s]*)\)/)[1].replace(/\s/g, '').split(',');
+ var body = HTMLCodeStr.match(/\{([\s\S]*)\}/m)[1];
for (var i=this.htmlTags.length; --i >= 0; ) {
body = body.replace(new RegExp('(^|[^\\w.])(' + this.htmlTags[i] + ')([\\s]*(?=\\())', 'g'), '$1Mooml.engine.tags.$2$3')
@@ -194,13 +194,13 @@ var Mooml = {
Mooml.Template = new Class({
nodes: [],
- initialize: function(name, code, options) {
+ initialize: function(name, HTMLCode, options) {
if (options && options.elementRefs && typeof(options.elementRefs) === "object") {
this.elementRefs = options.elementRefs;
}
this.name = name;
- this.code = code;
+ this.HTMLCode = HTMLCode;
this.prepared = false;
},
@@ -219,11 +219,11 @@ Mooml.Templates = new Class({
/**
* Registers a new template for later use or returns an existing template with that name
* @param {String} name The name of the template
- * @param {Function} code The code function of the template
+ * @param {Function} HTMLCode The code function of the template
*/
- registerTemplate: function(name, code, options) {
+ registerTemplate: function(name, HTMLCode, options) {
var template = this.templates[name];
- return (template)? template : this.templates[name] = new Mooml.Template(name, code, options);
+ return (template)? template : this.templates[name] = new Mooml.Template(name, HTMLCode, options);
},
/**

0 comments on commit 762a7b8

Please sign in to comment.