Comparing version 2.0.8-rc to 2.0.10-rc
{ | ||
"name": "etpl", | ||
"version": "2.0.8-rc", | ||
"version": "2.0.10-rc", | ||
"contributors": [ | ||
@@ -5,0 +5,0 @@ { "name": "erik", "email": "errorrik@gmail.com" }, |
@@ -740,3 +740,3 @@ /** | ||
function VarCommand( value, engine ) { | ||
if ( !/^\s*([a-z0-9_]+)\s*=(.*)$/i.test( value ) ) { | ||
if ( !/^\s*([a-z0-9_]+)\s*=([\s\S]*)$/i.test( value ) ) { | ||
throw new Error( 'Invalid ' + this.type + ' syntax: ' + value ); | ||
@@ -762,3 +762,3 @@ } | ||
function FilterCommand( value, engine ) { | ||
if ( !/^\s*([a-z0-9_-]+)\s*(\((.*)\))?\s*$/i.test( value ) ) { | ||
if ( !/^\s*([a-z0-9_-]+)\s*(\(([\s\S]*)\))?\s*$/i.test( value ) ) { | ||
throw new Error( 'Invalid ' + this.type + ' syntax: ' + value ); | ||
@@ -784,3 +784,3 @@ } | ||
function UseCommand( value, engine ) { | ||
if ( !/^\s*([a-z0-9_-]+)\s*(\((.*)\))?\s*$/i.test( value ) ) { | ||
if ( !/^\s*([a-z0-9_-]+)\s*(\(([\s\S]*)\))?\s*$/i.test( value ) ) { | ||
throw new Error( 'Invalid ' + this.type + ' syntax: ' + value ); | ||
@@ -1611,3 +1611,3 @@ } | ||
function ( text ) { // <!--...-->内文本的处理函数 | ||
var match = /^\s*(\/)?([a-z]+)\s*(:(.*))?$/.exec( text ); | ||
var match = /^\s*(\/)?([a-z]+)\s*(:([\s\S]*))?$/.exec( text ); | ||
@@ -1614,0 +1614,0 @@ // 符合command规则,并且存在相应的Command类,说明是合法有含义的Command |
@@ -7,2 +7,9 @@ define( | ||
etpl.addFilter( 'filter-lower', function (source, saveInitial) { | ||
if (saveInitial) { | ||
return source.charAt(0) + source.slice(1).toLowerCase(); | ||
} | ||
return source.toLowerCase(); | ||
}); | ||
describe('Filter', function() { | ||
@@ -20,13 +27,12 @@ it('can filter a piece of text', function() { | ||
it('param can be passed', function() { | ||
etpl.addFilter( 'filter-lower', function (source, saveInitial) { | ||
if (saveInitial) { | ||
return source.charAt(0) + source.slice(1).toLowerCase(); | ||
} | ||
return source.toLowerCase(); | ||
}); | ||
var renderer = etpl.compile( text['tpl-param'] ); | ||
expect(renderer()).toEqual(text['expect-param']); | ||
}); | ||
it('command literal allow break line', function() { | ||
var renderer = etpl.compile( text['tpl-param-break-line'] ); | ||
expect(renderer()).toEqual(text['expect-param']); | ||
}); | ||
}); | ||
} | ||
); |
@@ -38,2 +38,7 @@ define( | ||
}); | ||
it('command literal allow break line', function() { | ||
var renderer = etpl.getRenderer('forItemIndexTargetBreakLine'); | ||
expect(renderer(data)).toEqual(text['expect-forItemIndexTarget']); | ||
}); | ||
}); | ||
@@ -40,0 +45,0 @@ |
@@ -36,2 +36,7 @@ define( | ||
it('command literal allow break line', function() { | ||
var renderer = etpl.getRenderer('ifComplexTargetBreakLine'); | ||
expect(renderer( {num:1,str:"1"} )).toEqual(text['expect-ifComplexTarget']); | ||
}); | ||
it('"if" can be nested', function() { | ||
@@ -38,0 +43,0 @@ var renderer = etpl.getRenderer('ifNestedTarget'); |
@@ -7,4 +7,5 @@ define( | ||
var render = etpl.compile( text['normal'] ); | ||
var renderAutoclose = etpl.compile( text['auto-close'] ); | ||
var renderAutoclose = etpl.getRenderer( 'simpleTarget-autoclose' ); | ||
@@ -11,0 +12,0 @@ describe('Simple Target', function() { |
@@ -18,2 +18,7 @@ define( | ||
it('command literal allow break line', function() { | ||
var renderer = etpl.getRenderer('useSimpleTargetBreakLine'); | ||
expect(renderer(data)).toEqual(text['expect-useSimpleTarget']); | ||
}); | ||
it('can not read data of caller', function() { | ||
@@ -20,0 +25,0 @@ var renderer = etpl.getRenderer('useEngineTarget'); |
@@ -13,2 +13,7 @@ define( | ||
it('command literal allow break line', function() { | ||
var renderer = etpl.compile( text['tpl-breakline'] ); | ||
expect(renderer()).toEqual(text['expect-breakline']); | ||
}); | ||
it('has higher priority than data variable', function() { | ||
@@ -15,0 +20,0 @@ var data = { |
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
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
Sorry, the diff of this file is not supported yet
856325
75
10877