Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Upgraded to Mootools 1.3

Signed-off-by: Eneko Alonso <eneko.alonso@gmail.com>
  • Loading branch information...
commit d238571c18b465313d21a5e4f0c3671a4655c6d1 1 parent d7b19f9
@eneko authored
View
2  Source/mooml-globalize.js
@@ -1,7 +1,7 @@
/*
---
script: mooml-globalize.js
-version: 1.2.3
+version: 1.3.0
description: Mooml Globalize makes all template functions available in the global scope of the window object.
license: MIT-style
download: http://mootools.net/forge/p/mooml
View
26 Source/mooml.js
@@ -1,7 +1,7 @@
/*
---
script: mooml.js
-version: 1.2.4
+version: 1.3.0
description: Mooml is a javasctript templating engine for HTML generation, powered by Mootools.
license: MIT-style
download: http://mootools.net/forge/p/mooml
@@ -23,9 +23,9 @@ provides:
- Mooml.Templates
requires:
-- core/1.2.4:Class
-- core/1.2.4:Elements
-- core/1.2.4:Array
+- core/1.3.0:Class
+- core/1.3.0:Elements
+- core/1.3.0:Array
...
*/
@@ -78,9 +78,9 @@ var Mooml = {
template.prepared = true;
}
- $splat($pick(data, {})).each(function(params, index) {
+ Array.from([data, {}].pick()).each(function(params, index) {
template.code(params, index);
- elements.extend(template.nodes.filter(function(node) {
+ elements.append(template.nodes.filter(function(node) {
return node.getParent() === null;
}));
template.nodes.empty();
@@ -89,7 +89,7 @@ var Mooml = {
this.engine.callstack.pop();
if (this.engine.callstack.length) {
if (template.elementRefs) {
- $extend(this.engine.callstack.getLast().elementRefs, template.elementRefs);
+ Array.extend(this.engine.callstack.getLast().elementRefs, template.elementRefs);
}
}
@@ -111,8 +111,8 @@ var Mooml = {
for (var i=0, l=arguments.length; i<l; i++) {
var argument = arguments[i];
- if ($type(argument) === "function") argument = argument();
- switch ($type(argument)) {
+ if (typeOf(argument) === "function") argument = argument();
+ switch (typeOf(argument)) {
case "array":
case "element":
case "collection": {
@@ -138,7 +138,7 @@ var Mooml = {
template.elementRefs[argument.id] = el;
}
el.set(argument);
- } else if ($type(argument.toElement) == "function") {
+ } else if (typeOf(argument.toElement) == "function") {
el.adopt(argument.toElement());
}
break;
@@ -198,7 +198,7 @@ Mooml.Template = new Class({
/**
* Mixin for implemenation in Mootools classes: Implements: [Mooml.Templates, Options, ...]
*/
-Mooml.Templates = {
+Mooml.Templates = new Class({
templates: {},
/**
@@ -221,13 +221,13 @@ Mooml.Templates = {
return (template)? template.render(data) : null;
}
-}
+});
/**
* Implement Mooml.Templates into Mooml and alias for backwards compatibility
*/
-$extend(Mooml, Mooml.Templates);
+Object.append(Mooml, new Mooml.Templates());
Mooml.register = Mooml.registerTemplate;
Mooml.render = Mooml.renderTemplate;
View
3  Test/index.html
@@ -32,7 +32,7 @@
<li>Mooml related posts: <a href="http://dev.enekoalonso.com/tag/mooml/">http://dev.enekoalonso.com/tag/mooml/</a></li>
</ul>
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/mootools/1.2.4/mootools-yui-compressed.js"></script>
+ <script type="text/javascript" src="mootools-core-1.3-full-nocompat.js"></script>
<!--script type="text/javascript" src="http://github.com/eneko/mooml/raw/master/Source/mooml.js"></script-->
<script type="text/javascript" src="../Source/mooml.js"></script>
<script type="text/javascript">
@@ -52,6 +52,7 @@
}
Mooml.register('twitter-search-item', function(entry, index) {
+ console.log('twitter-search-item: ', index);
li({ id: "tweet-" + entry.id, styles: {
listStyle: 'none',
background: index & 1 ? '#fff' : '#ddd',
View
5,367 Test/mootools-core-1.3-full-nocompat.js
5,367 additions, 0 deletions not shown
View
146 Test/perftest.html
@@ -1,73 +1,73 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <title>Mooml Performance Tests</title>
- <style>
- * { margin: 0; padding: 0;}
- body { font: 11px Arial; }
- </style>
-</head>
-<body>
-</body>
-</html>
-<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/mootools/1.2.4/mootools-yui-compressed.js"></script>
-<script type="text/javascript" src="../Source/mooml.js"></script>
-<script type="text/javascript">
-var queue=[];
-Mooml.register('emptydiv', function() { div(); });
-Mooml.register('div', function(value) { div(value); });
-
-function log() {
- new Element('p', { text: $A(arguments).join('') }).inject(document.body);
-}
-function timeDiff(start, end) {
- return end.getTime() - start.getTime() + 'ms';
-}
-function test(desc, fn) {
- queue.push({ desc: desc, fn: fn });
-}
-function start() {
- if (!queue.length) return;
- var test = queue.shift();
- var then = new Date();
- test.fn();
- log(test.desc, ' ', timeDiff(then, new Date()));
- setTimeout(start, 10);
-}
-
-// Render 10,000 empty divs
-test('10k empty divs:', function() {
- for (var i=0; i<1E4; i++) {
- Mooml.render('emptydiv');
- }
-});
-
-// Render 10,000 divs with text
-
-test('10k divs with text:', function() {
- for (var i=0; i<1E4; i++) {
- Mooml.render('div', '.span.lorem./span. .p..b..u.ipsum.u dolor./b. sit./p.');
- }
-});
-
-
-// Render 10,000 divs with html
-
-test('10k divs with html:', function() {
- for (var i=0; i<1E4; i++) {
- Mooml.render('div', '<span>lorem</span> <p><b><u>ipsum<u> dolor</b> sit</p>');
- }
-});
-
-// Render 5x10,000 divs with text
-
-test('5x10k divs with text:', function() {
- for (var i=0; i<1E4; i++) {
- Mooml.render('div', ['a','b','c','d','e']);
- }
-});
-
-start();
-
-</script>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>Mooml Performance Tests</title>
+ <style>
+ * { margin: 0; padding: 0;}
+ body { font: 11px Arial; }
+ </style>
+</head>
+<body>
+</body>
+</html>
+<script type="text/javascript" src="mootools-core-1.3-full-nocompat.js"></script>
+<script type="text/javascript" src="../Source/mooml.js"></script>
+<script type="text/javascript">
+var queue=[];
+Mooml.register('emptydiv', function() { div(); });
+Mooml.register('div', function(value) { div(value); });
+
+function log() {
+ new Element('p', { text: Array.from(arguments).join('') }).inject(document.body);
+}
+function timeDiff(start, end) {
+ return end.getTime() - start.getTime() + 'ms';
+}
+function test(desc, fn) {
+ queue.push({ desc: desc, fn: fn });
+}
+function start() {
+ if (!queue.length) return;
+ var test = queue.shift();
+ var then = new Date();
+ test.fn();
+ log(test.desc, ' ', timeDiff(then, new Date()));
+ setTimeout(start, 10);
+}
+
+// Render 10,000 empty divs
+test('10k empty divs:', function() {
+ for (var i=0; i<1E4; i++) {
+ Mooml.render('emptydiv');
+ }
+});
+
+// Render 10,000 divs with text
+
+test('10k divs with text:', function() {
+ for (var i=0; i<1E4; i++) {
+ Mooml.render('div', '.span.lorem./span. .p..b..u.ipsum.u dolor./b. sit./p.');
+ }
+});
+
+
+// Render 10,000 divs with html
+
+test('10k divs with html:', function() {
+ for (var i=0; i<1E4; i++) {
+ Mooml.render('div', '<span>lorem</span> <p><b><u>ipsum<u> dolor</b> sit</p>');
+ }
+});
+
+// Render 5x10,000 divs with text
+
+test('5x10k divs with text:', function() {
+ for (var i=0; i<1E4; i++) {
+ Mooml.render('div', ['a','b','c','d','e']);
+ }
+});
+
+start();
+
+</script>
View
200 Test/test.html
@@ -1,100 +1,100 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
-<head>
- <title>Mooml QUnit Tests</title>
- <link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />
-</head>
-<body>
- <h1 id="qunit-header">QUnit example</h1>
- <h2 id="qunit-banner"></h2>
- <h2 id="qunit-userAgent"></h2>
- <ol id="qunit-tests"></ol>
-</body>
-</html>
-<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/mootools/1.2.4/mootools-yui-compressed.js"></script>
-<!--script type="text/javascript" src="http://github.com/eneko/mooml/raw/master/Source/mooml.js"></script-->
-<script type="text/javascript" src="../Source/mooml.js"></script>
-<script type="text/javascript" src="qunit.js"></script>
-<script type="text/javascript">
-var templateElements, data;
-
-// Templates used in the tests
-Mooml.register('div-text-value', function(value) {
- div({text:value});
-});
-Mooml.register('div-value', function(value) {
- div(value);
-});
-Mooml.register('string-test', function(data) {
- div(
- 'before',
- div(data),
- 'after'
- );
-});
-
-// *******************************************************
-
-module("Parameter Tests");
-
-test('Passing a string', function() {
- var wrapper = new Element('div');
- wrapper.adopt(Mooml.render('string-test', 'test-string'));
- equals(wrapper.innerHTML, '<div>before<div>test-string</div>after</div>', 'InnerHTML matches string');
-});
-
-test('Passing HTML', function() {
- var wrapper = new Element('div');
- wrapper.adopt(Mooml.render('string-test', '<span>lorem <b>ipsum</b></span>'));
- equals(wrapper.innerHTML, '<div>before<div><span>lorem <b>ipsum</b></span></div>after</div>', 'InnerHTML matches html');
-});
-
-test('Passing "false" parameter', function() {
- templateElements = Mooml.render('div-text-value', false);
- equals(templateElements.tagName, 'DIV', 'Element created is a DIV');
- equals(templateElements.innerHTML, 'false', 'Inner HTML is "false"');
-});
-
-test('Passing "true" parameter', function() {
- templateElements = Mooml.render('div-text-value', true);
- equals(templateElements.tagName, 'DIV', 'Element created is a DIV');
- equals(templateElements.innerHTML, 'true', 'Inner HTML is "true"');
-});
-
-test('Passing an array of string values', function() {
- data = ['bob', 'john', 'eric', 'carlos', 'chris'];
- templateElements = Mooml.render('div-value', data);
- equals(templateElements.length, data.length, data.length + ' elements created');
- data.each(function(value, index) {
- equals(templateElements[index].innerHTML, data[index], 'Inner HTML equals data');
- });
-});
-
-test('Passing an array of number values', function() {
- data = [5, -56, 765, 342, 1000000, 1E6, 3.1415, 0.123456789];
- templateElements = Mooml.render('div-value', data);
- equals(templateElements.length, data.length, data.length + ' elements created');
- data.each(function(value, index) {
- equals(templateElements[index].innerHTML, data[index], 'Inner HTML equals data: ' + data[index]);
- });
-});
-
-
-
-// *******************************************************
-
-module("Tag Tests");
-test("Create elements for each Mooml supported tag", function() {
- Mooml.htmlTags.each(function(tag) {
- Mooml.registerTemplate('tagtest-'+tag, function(data) {
- Mooml.engine.tags[data.tag]({id: data.tagid});
- });
- templateElements = Mooml.render('tagtest-'+tag, {tag: tag, tagid: 'tagid'});
- equals(templateElements.tagName, tag.toUpperCase(), 'Element tag matches');
- equals(templateElements.id, 'tagid', 'Element id matches');
- });
-});
-
-
-
-</script>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>Mooml QUnit Tests</title>
+ <link rel="stylesheet" href="qunit.css" type="text/css" media="screen" />
+</head>
+<body>
+ <h1 id="qunit-header">QUnit example</h1>
+ <h2 id="qunit-banner"></h2>
+ <h2 id="qunit-userAgent"></h2>
+ <ol id="qunit-tests"></ol>
+</body>
+</html>
+<script type="text/javascript" src="mootools-core-1.3-full-nocompat.js"></script>
+<!--script type="text/javascript" src="http://github.com/eneko/mooml/raw/master/Source/mooml.js"></script-->
+<script type="text/javascript" src="../Source/mooml.js"></script>
+<script type="text/javascript" src="qunit.js"></script>
+<script type="text/javascript">
+var templateElements, data;
+
+// Templates used in the tests
+Mooml.register('div-text-value', function(value) {
+ div({text:value});
+});
+Mooml.register('div-value', function(value) {
+ div(value);
+});
+Mooml.register('string-test', function(data) {
+ div(
+ 'before',
+ div(data),
+ 'after'
+ );
+});
+
+// *******************************************************
+
+module("Parameter Tests");
+
+test('Passing a string', function() {
+ var wrapper = new Element('div');
+ wrapper.adopt(Mooml.render('string-test', 'test-string'));
+ equals(wrapper.innerHTML, '<div>before<div>test-string</div>after</div>', 'InnerHTML matches string');
+});
+
+test('Passing HTML', function() {
+ var wrapper = new Element('div');
+ wrapper.adopt(Mooml.render('string-test', '<span>lorem <b>ipsum</b></span>'));
+ equals(wrapper.innerHTML, '<div>before<div><span>lorem <b>ipsum</b></span></div>after</div>', 'InnerHTML matches html');
+});
+
+test('Passing "false" parameter', function() {
+ templateElements = Mooml.render('div-text-value', false);
+ equals(templateElements.tagName, 'DIV', 'Element created is a DIV');
+ equals(templateElements.innerHTML, 'false', 'Inner HTML is "false"');
+});
+
+test('Passing "true" parameter', function() {
+ templateElements = Mooml.render('div-text-value', true);
+ equals(templateElements.tagName, 'DIV', 'Element created is a DIV');
+ equals(templateElements.innerHTML, 'true', 'Inner HTML is "true"');
+});
+
+test('Passing an array of string values', function() {
+ data = ['bob', 'john', 'eric', 'carlos', 'chris'];
+ templateElements = Mooml.render('div-value', data);
+ equals(templateElements.length, data.length, data.length + ' elements created');
+ data.each(function(value, index) {
+ equals(templateElements[index].innerHTML, data[index], 'Inner HTML equals data');
+ });
+});
+
+test('Passing an array of number values', function() {
+ data = [5, -56, 765, 342, 1000000, 1E6, 3.1415, 0.123456789];
+ templateElements = Mooml.render('div-value', data);
+ equals(templateElements.length, data.length, data.length + ' elements created');
+ data.each(function(value, index) {
+ equals(templateElements[index].innerHTML, data[index], 'Inner HTML equals data: ' + data[index]);
+ });
+});
+
+
+
+// *******************************************************
+
+module("Tag Tests");
+test("Create elements for each Mooml supported tag", function() {
+ Mooml.htmlTags.each(function(tag) {
+ Mooml.registerTemplate('tagtest-'+tag, function(data) {
+ Mooml.engine.tags[data.tag]({id: data.tagid});
+ });
+ templateElements = Mooml.render('tagtest-'+tag, {tag: tag, tagid: 'tagid'});
+ equals(templateElements.tagName, tag.toUpperCase(), 'Element tag matches');
+ equals(templateElements.id, 'tagid', 'Element id matches');
+ });
+});
+
+
+
+</script>
View
2  package.yml
@@ -2,5 +2,5 @@ name: Mooml
author: enekoalonso
category: Native
tags: [template, html, dom, element, engine, templating]
-current: 1.2.4
+current: 1.3.0
demo: http://enekoalonso.com/projects/mooml/
Please sign in to comment.
Something went wrong with that request. Please try again.