Comparing version 0.9.9 to 0.9.11
@@ -7,3 +7,5 @@ { | ||
}, | ||
"bin" : { "Templ8" : "./bin/Templ8" }, | ||
"bin" : { | ||
"Templ8" : "./bin/Templ8" | ||
}, | ||
"description" : "JavaScript Client/ Server Template Engine", | ||
@@ -20,5 +22,5 @@ "dependencies" : { | ||
"type" : "MIT", | ||
"url" : "https://raw.github.com/constantology/Templ8/master/LICENSE" | ||
"url" : "https://raw.github.com/constantology/Templ8/master/LICENSE" | ||
} ], | ||
"main" : "./Templ8.js", | ||
"main" : "./Templ8", | ||
"name" : "Templ8", | ||
@@ -30,5 +32,5 @@ "repository" : { | ||
"scripts" : { | ||
"test" : "mocha -c --globals mocha,expect,m8,Templ8,tpl_test_value -R spec -u tdd ./test" | ||
"test" : "mocha -c --ignore-leaks -R spec -u tdd ./test/*.test.js" | ||
}, | ||
"version" : "0.9.9" | ||
"version" : "0.9.11" | ||
} |
@@ -0,1 +1,3 @@ | ||
<!-- [![build status](https://secure.travis-ci.org/constantology/Templ8.png)](http://travis-ci.org/constantology/Templ8) --> | ||
#TODO: | ||
@@ -32,2 +34,6 @@ | ||
## Support | ||
Tested to work with nodejs, FF4+, Safari 5+, Chrome 7+, IE9+. Should technically work in any browser that supports [ecma 5]( http://kangax.github.com/es5-compat-table/) without throwing any JavaScript errors. | ||
## API | ||
@@ -34,0 +40,0 @@ |
@@ -13,3 +13,3 @@ !function() { | ||
str = typeof str == 'string' ? str : url; | ||
return str.link( ( !!~url.indexOf( '@' ) ? 'mailto:' : '' ) + url ); | ||
return '<a href="' + ( !!~url.indexOf( '@' ) ? 'mailto:' : '' ) + url + '">' + str + '</a>'; | ||
}, | ||
@@ -16,0 +16,0 @@ paragraph : function( str ) { return Templ8.stringify( str ).replace( /([^\r\n]+)/gm, '<p>$1</p>' ); }, |
@@ -1,7 +0,9 @@ | ||
typeof m8 !== 'undefined' || ( m8 = require( 'm8' ) ); | ||
typeof m8 !== 'undefined' || ( m8 = require( 'm8' ) ); | ||
typeof Templ8 !== 'undefined' || ( Templ8 = require( 'Templ8' ) ); | ||
typeof expect !== 'undefined' || ( expect = require( 'expect.js' ) ); | ||
typeof chai !== 'undefined' || ( chai = require( 'chai' ) ); | ||
m8.ENV != 'commonjs' || require( '../Templ8.Filter.html' ); | ||
expect = chai.expect; | ||
suite( 'Templ8', function() { | ||
@@ -243,5 +245,5 @@ | ||
expect( tpl0.parse( data ) ).to.eql( 600 ); | ||
expect( tpl1.parse( data ) ).to.eql( 6 ); | ||
expect( tpl2.parse( data ).trim() ).to.eql( 'ultrices.sit.amet@nullamagnamalesuada.ca' ); | ||
expect( tpl0.parse( data ) ).to.equal( '600' ); | ||
expect( tpl1.parse( data ) ).to.equal( '6' ); | ||
expect( tpl2.parse( data ).trim() ).to.equal( 'ultrices.sit.amet@nullamagnamalesuada.ca' ); | ||
@@ -256,5 +258,5 @@ done(); | ||
expect( tpl0.parse( data ).trim() ).to.eql( '<strong>600</strong>' ); | ||
expect( tpl1.parse( data ).trim() ).to.eql( '<em>6</em>' ); | ||
expect( tpl2.parse( data ).trim() ).to.eql( '<strong><a href="mailto:ultrices.sit.amet@nullamagnamalesuada.ca">ultrices.sit.amet@nullamagnamalesuada.ca</a></strong>' ); | ||
expect( tpl0.parse( data ).trim() ).to.equal( '<strong>600</strong>' ); | ||
expect( tpl1.parse( data ).trim() ).to.equal( '<em>6</em>' ); | ||
expect( tpl2.parse( data ).trim() ).to.equal( '<strong><a href="mailto:ultrices.sit.amet@nullamagnamalesuada.ca">ultrices.sit.amet@nullamagnamalesuada.ca</a></strong>' ); | ||
@@ -267,3 +269,3 @@ done(); | ||
expect( tpl0.parse( data ).trim() ).to.eql( '<p>email - <a href="mailto:ultrices.sit.amet@nullamagnamalesuada.ca">Zahir</a></p>' ); | ||
expect( tpl0.parse( data ).trim() ).to.equal( '<p>email - <a href="mailto:ultrices.sit.amet@nullamagnamalesuada.ca">Zahir</a></p>' ); | ||
@@ -278,5 +280,5 @@ done(); | ||
expect( tpl0.parse( data ).trim() ).to.eql( 'ultrices.sit.amet@nullamagnamalesuada.ca' ); | ||
expect( tpl1.parse( data ).trim() ).to.eql( '<p>email - <a href="mailto:ultrices.sit.amet@nullamagnamalesuada.ca">Zahir</a></p>' ); | ||
expect( tpl2.parse( data ).trim() ).to.be.empty(); | ||
expect( tpl0.parse( data ).trim() ).to.equal( 'ultrices.sit.amet@nullamagnamalesuada.ca' ); | ||
expect( tpl1.parse( data ).trim() ).to.equal( '<p>email - <a href="mailto:ultrices.sit.amet@nullamagnamalesuada.ca">Zahir</a></p>' ); | ||
expect( tpl2.parse( data ).trim() ).to.be.empty; | ||
@@ -290,4 +292,4 @@ done(); | ||
expect( tpl0.parse( data ).trim() ).to.be.empty(); | ||
expect( tpl1.parse( data ).trim() ).to.eql( '<p>email - <a href="mailto:ultrices.sit.amet@nullamagnamalesuada.ca">Zahir</a></p>' ); | ||
expect( tpl0.parse( data ).trim() ).to.be.empty; | ||
expect( tpl1.parse( data ).trim() ).to.equal( '<p>email - <a href="mailto:ultrices.sit.amet@nullamagnamalesuada.ca">Zahir</a></p>' ); | ||
@@ -306,4 +308,4 @@ done(); | ||
expect( tpl0.parse( data ).trim() ).to.eql( '<p>email - <a href="mailto:ultrices.sit.amet@nullamagnamalesuada.ca">Zahir</a></p>' ); | ||
expect( tpl1.parse( data ).trim() ).to.be.empty(); | ||
expect( tpl0.parse( data ).trim() ).to.equal( '<p>email - <a href="mailto:ultrices.sit.amet@nullamagnamalesuada.ca">Zahir</a></p>' ); | ||
expect( tpl1.parse( data ).trim() ).to.be.empty; | ||
@@ -322,4 +324,4 @@ done(); | ||
expect( tpl0.parse( data ).trim() ).to.eql( '<p>email - <a href="mailto:ultrices.sit.amet@nullamagnamalesuada.ca">Zahir</a></p>' ); | ||
expect( tpl1.parse( data ).trim() ).to.be.empty(); | ||
expect( tpl0.parse( data ).trim() ).to.equal( '<p>email - <a href="mailto:ultrices.sit.amet@nullamagnamalesuada.ca">Zahir</a></p>' ); | ||
expect( tpl1.parse( data ).trim() ).to.be.empty; | ||
@@ -336,3 +338,3 @@ done(); | ||
expect( tpl0.parse( data ).trim() ).to.eql( '<p>email - <a href="mailto:ultrices.sit.amet@nullamagnamalesuada.ca">Zahir</a></p>' ); | ||
expect( tpl0.parse( data ).trim() ).to.equal( '<p>email - <a href="mailto:ultrices.sit.amet@nullamagnamalesuada.ca">Zahir</a></p>' ); | ||
@@ -349,3 +351,3 @@ done(); | ||
expect( tpl0.parse( data ).trim() ).to.eql( '<p>email - <a href="mailto:ultrices.sit.amet@nullamagnamalesuada.ca">Zahir</a></p>' ); | ||
expect( tpl0.parse( data ).trim() ).to.equal( '<p>email - <a href="mailto:ultrices.sit.amet@nullamagnamalesuada.ca">Zahir</a></p>' ); | ||
@@ -366,6 +368,6 @@ done(); | ||
expect( tpl0.parse( { foo : 1 } ) ).to.eql( 'foo equals 1' ); | ||
expect( tpl0.parse( { foo : 0 } ) ).to.eql( 'foo equals 0' ); | ||
expect( tpl0.parse( { foo : -1 } ) ).to.eql( 'foo equals -1' ); | ||
expect( tpl0.parse( { foo : 2 } ) ).to.eql( 'foo equals 2' ); | ||
expect( tpl0.parse( { foo : 1 } ) ).to.equal( 'foo equals 1' ); | ||
expect( tpl0.parse( { foo : 0 } ) ).to.equal( 'foo equals 0' ); | ||
expect( tpl0.parse( { foo : -1 } ) ).to.equal( 'foo equals -1' ); | ||
expect( tpl0.parse( { foo : 2 } ) ).to.equal( 'foo equals 2' ); | ||
@@ -403,8 +405,8 @@ done(); | ||
expect( tpl0.parse( data ) ).to.eql( e1 ); | ||
expect( tpl1.parse( data ) ).to.eql( e1 ); | ||
expect( tpl2.parse( data ) ).to.eql( e2 ); | ||
expect( tpl3.parse( data ) ).to.eql( e3 ); | ||
expect( tpl4.parse( data ) ).to.eql( e2 ); | ||
expect( tpl5.parse( data ) ).to.eql( e3 ); | ||
expect( tpl0.parse( data ) ).to.equal( e1 ); | ||
expect( tpl1.parse( data ) ).to.equal( e1 ); | ||
expect( tpl2.parse( data ) ).to.equal( e2 ); | ||
expect( tpl3.parse( data ) ).to.equal( e3 ); | ||
expect( tpl4.parse( data ) ).to.equal( e2 ); | ||
expect( tpl5.parse( data ) ).to.equal( e3 ); | ||
@@ -419,3 +421,3 @@ done(); | ||
expect( tpl0.parse( data ) ).to.eql( '<index>0</index><prevIndex>undefined</prevIndex><nextIndex>1</nextIndex><first>Baxter</first><last>Fleur</last><next>Alyssa</next><prev></prev><index>1</index><prevIndex>0</prevIndex><nextIndex>2</nextIndex><first>Baxter</first><last>Fleur</last><next>Fleur</next><prev>Baxter</prev><index>2</index><prevIndex>1</prevIndex><nextIndex>undefined</nextIndex><first>Baxter</first><last>Fleur</last><next></next><prev>Alyssa</prev>' ); | ||
expect( tpl0.parse( data ) ).to.equal( '<index>0</index><prevIndex>undefined</prevIndex><nextIndex>1</nextIndex><first>Baxter</first><last>Fleur</last><next>Alyssa</next><prev></prev><index>1</index><prevIndex>0</prevIndex><nextIndex>2</nextIndex><first>Baxter</first><last>Fleur</last><next>Fleur</next><prev>Baxter</prev><index>2</index><prevIndex>1</prevIndex><nextIndex>undefined</nextIndex><first>Baxter</first><last>Fleur</last><next></next><prev>Alyssa</prev>' ); | ||
@@ -461,10 +463,10 @@ done(); | ||
expect( tpl0.parse( data ) ).to.eql( e1 ); | ||
expect( tpl1.parse( data ) ).to.eql( e1 ); | ||
expect( tpl2.parse( data ) ).to.eql( e2 ); | ||
expect( tpl3.parse( data ) ).to.eql( e3 ); | ||
expect( tpl4.parse( data ) ).to.eql( e2 ); | ||
expect( tpl5.parse( data ) ).to.eql( e3 ); | ||
expect( tpl6.parse( data ) ).to.eql( e2 ); | ||
expect( tpl7.parse( data ) ).to.eql( e3 ); | ||
expect( tpl0.parse( data ) ).to.equal( e1 ); | ||
expect( tpl1.parse( data ) ).to.equal( e1 ); | ||
expect( tpl2.parse( data ) ).to.equal( e2 ); | ||
expect( tpl3.parse( data ) ).to.equal( e3 ); | ||
expect( tpl4.parse( data ) ).to.equal( e2 ); | ||
expect( tpl5.parse( data ) ).to.equal( e3 ); | ||
expect( tpl6.parse( data ) ).to.equal( e2 ); | ||
expect( tpl7.parse( data ) ).to.equal( e3 ); | ||
@@ -493,5 +495,5 @@ done(); | ||
expect( tpl0.parse( data ) ).to.eql( '<p>PASS</p>' ); | ||
expect( tpl1.parse( data ) ).to.eql( '<p>PASS</p>' ); | ||
expect( tpl2.parse( data ) ).to.eql( '<p>PASS</p>' ); | ||
expect( tpl0.parse( data ) ).to.equal( '<p>PASS</p>' ); | ||
expect( tpl1.parse( data ) ).to.equal( '<p>PASS</p>' ); | ||
expect( tpl2.parse( data ) ).to.equal( '<p>PASS</p>' ); | ||
@@ -511,4 +513,4 @@ done(); | ||
expect( tpl1.parse( data ) ).to.eql( '<p>Test data</p>' ); | ||
// expect( tpl2.parse( data ) ).to.eql( '<p><strong>Test data</strong></p>' ); | ||
expect( tpl1.parse( data ) ).to.equal( '<p>Test data</p>' ); | ||
// expect( tpl2.parse( data ) ).to.equal( '<p><strong>Test data</strong></p>' ); | ||
@@ -531,24 +533,24 @@ done(); | ||
expect( tpl0.parse( { items : [1, 2, 3, 4, 5, 6] } ) ).to.eql( '123456' ); | ||
expect( tpl1.parse( { items : [1, 2, 3, 4, 5, 6] } ) ).to.eql( '123' ); | ||
expect( tpl2.parse( { items : [1, 2, 3, 4, 5, 6] } ) ).to.eql( '123' ); | ||
expect( tpl3.parse( { items : [1, 2, 3, 4, 5, 6] } ) ).to.eql( '123456' ); | ||
expect( tpl4.parse( { items : [1, 2, 3, 4, 5, 6] } ) ).to.eql( '123' ); | ||
expect( tpl5.parse( { items : [1, 2, 3, 4, 5, 6] } ) ).to.eql( '123' ); | ||
expect( tpl6.parse( { items : [1, 2, 3, 4, 5, 6] } ) ).to.eql( '1357911' );// | ||
expect( tpl7.parse( { items : [1, 2, 3, 4, 5, 6] } ) ).to.eql( '135' );// | ||
expect( tpl8.parse( { items : [1, 2, 3, 4, 5, 6] } ) ).to.eql( '123' ); | ||
expect( tpl9.parse( { items : [1, 2, 3, 4, 5, 6] } ) ).to.eql( '35' );// | ||
expect( tpl10.parse( { items : [1, 2, 3, 4, 5, 6] } ) ).to.eql( '7911' );// | ||
expect( tpl0.parse( { items : { one : 1, two : 2, three : 3, four : 4, five : 5, six : 6 } } ) ).to.eql( '123456' ); | ||
expect( tpl1.parse( { items : { one : 1, two : 2, three : 3, four : 4, five : 5, six : 6 } } ) ).to.eql( '123' ); | ||
expect( tpl2.parse( { items : { one : 1, two : 2, three : 3, four : 4, five : 5, six : 6 } } ) ).to.eql( '123' ); | ||
expect( tpl3.parse( { items : { one : 1, two : 2, three : 3, four : 4, five : 5, six : 6 } } ) ).to.eql( '123456' ); | ||
expect( tpl4.parse( { items : { one : 1, two : 2, three : 3, four : 4, five : 5, six : 6 } } ) ).to.eql( '123' ); | ||
expect( tpl5.parse( { items : { one : 1, two : 2, three : 3, four : 4, five : 5, six : 6 } } ) ).to.eql( '123' ); | ||
expect( tpl6.parse( { items : { one : 1, two : 2, three : 3, four : 4, five : 5, six : 6 } } ) ).to.eql( '1one2two3three4four5five6six' ); | ||
expect( tpl7.parse( { items : { one : 1, two : 2, three : 3, four : 4, five : 5, six : 6 } } ) ).to.eql( '1one2two3three' ); | ||
expect( tpl8.parse( { items : { one : 1, two : 2, three : 3, four : 4, five : 5, six : 6 } } ) ).to.eql( '123' ); | ||
expect( tpl9.parse( { items : { one : 1, two : 2, three : 3, four : 4, five : 5, six : 6 } } ) ).to.eql( '2two3three' ); | ||
expect( tpl10.parse( { items : { one : 1, two : 2, three : 3, four : 4, five : 5, six : 6 } } ) ).to.eql( '4four5five6six' ); | ||
expect( tpl0.parse( { items : [1, 2, 3, 4, 5, 6] } ) ).to.equal( '123456' ); | ||
expect( tpl1.parse( { items : [1, 2, 3, 4, 5, 6] } ) ).to.equal( '123' ); | ||
expect( tpl2.parse( { items : [1, 2, 3, 4, 5, 6] } ) ).to.equal( '123' ); | ||
expect( tpl3.parse( { items : [1, 2, 3, 4, 5, 6] } ) ).to.equal( '123456' ); | ||
expect( tpl4.parse( { items : [1, 2, 3, 4, 5, 6] } ) ).to.equal( '123' ); | ||
expect( tpl5.parse( { items : [1, 2, 3, 4, 5, 6] } ) ).to.equal( '123' ); | ||
expect( tpl6.parse( { items : [1, 2, 3, 4, 5, 6] } ) ).to.equal( '1357911' );// | ||
expect( tpl7.parse( { items : [1, 2, 3, 4, 5, 6] } ) ).to.equal( '135' );// | ||
expect( tpl8.parse( { items : [1, 2, 3, 4, 5, 6] } ) ).to.equal( '123' ); | ||
expect( tpl9.parse( { items : [1, 2, 3, 4, 5, 6] } ) ).to.equal( '35' );// | ||
expect( tpl10.parse( { items : [1, 2, 3, 4, 5, 6] } ) ).to.equal( '7911' );// | ||
expect( tpl0.parse( { items : { one : 1, two : 2, three : 3, four : 4, five : 5, six : 6 } } ) ).to.equal( '123456' ); | ||
expect( tpl1.parse( { items : { one : 1, two : 2, three : 3, four : 4, five : 5, six : 6 } } ) ).to.equal( '123' ); | ||
expect( tpl2.parse( { items : { one : 1, two : 2, three : 3, four : 4, five : 5, six : 6 } } ) ).to.equal( '123' ); | ||
expect( tpl3.parse( { items : { one : 1, two : 2, three : 3, four : 4, five : 5, six : 6 } } ) ).to.equal( '123456' ); | ||
expect( tpl4.parse( { items : { one : 1, two : 2, three : 3, four : 4, five : 5, six : 6 } } ) ).to.equal( '123' ); | ||
expect( tpl5.parse( { items : { one : 1, two : 2, three : 3, four : 4, five : 5, six : 6 } } ) ).to.equal( '123' ); | ||
expect( tpl6.parse( { items : { one : 1, two : 2, three : 3, four : 4, five : 5, six : 6 } } ) ).to.equal( '1one2two3three4four5five6six' ); | ||
expect( tpl7.parse( { items : { one : 1, two : 2, three : 3, four : 4, five : 5, six : 6 } } ) ).to.equal( '1one2two3three' ); | ||
expect( tpl8.parse( { items : { one : 1, two : 2, three : 3, four : 4, five : 5, six : 6 } } ) ).to.equal( '123' ); | ||
expect( tpl9.parse( { items : { one : 1, two : 2, three : 3, four : 4, five : 5, six : 6 } } ) ).to.equal( '2two3three' ); | ||
expect( tpl10.parse( { items : { one : 1, two : 2, three : 3, four : 4, five : 5, six : 6 } } ) ).to.equal( '4four5five6six' ); | ||
@@ -563,3 +565,3 @@ done(); | ||
expect( m8.global.tpl_test_value ).to.be( true ); | ||
expect( m8.global.tpl_test_value ).to.be.true; | ||
@@ -572,3 +574,3 @@ done(); | ||
expect( tpl.parse( data ) ).to.be.empty(); | ||
expect( tpl.parse( data ) ).to.be.empty; | ||
@@ -579,3 +581,3 @@ done(); | ||
test( '<static> format can perform simple string substitutions', function( done ) { | ||
expect( Templ8.format( 'Hello {3}, a {0}, a {1}, a {0}, {1}, {2}, HIT IT!!!', 1, 2, 3, 'World' ) ).to.eql( 'Hello World, a 1, a 2, a 1, 2, 3, HIT IT!!!' ); | ||
expect( Templ8.format( 'Hello {3}, a {0}, a {1}, a {0}, {1}, {2}, HIT IT!!!', 1, 2, 3, 'World' ) ).to.equal( 'Hello World, a 1, a 2, a 1, 2, 3, HIT IT!!!' ); | ||
@@ -586,3 +588,3 @@ done(); | ||
test( '<static> gsub can perform simple string substitutions', function( done ) { | ||
expect( Templ8.gsub( 'Hello {name}, a {first}, a {second}, a {first}, {second}, {third}, HIT IT!!!', { first : 1, second : 2, third : 3, name : 'World' } ) ).to.eql( 'Hello World, a 1, a 2, a 1, 2, 3, HIT IT!!!' ); | ||
expect( Templ8.gsub( 'Hello {name}, a {first}, a {second}, a {first}, {second}, {third}, HIT IT!!!', { first : 1, second : 2, third : 3, name : 'World' } ) ).to.equal( 'Hello World, a 1, a 2, a 1, 2, 3, HIT IT!!!' ); | ||
@@ -589,0 +591,0 @@ done(); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
142276
20
1677
607