diff --git a/lib/dust-helpers.js b/lib/dust-helpers.js index 15cbc9c..d8b033a 100644 --- a/lib/dust-helpers.js +++ b/lib/dust-helpers.js @@ -202,18 +202,6 @@ var helpers = { return chunk; }, - "idx": function(chunk, context, bodies) { - var body = bodies.block; - // Will be removed in 1.6 - _deprecated("{@idx}"); - if(body) { - return body(chunk, context.push(context.stack.index)); - } - else { - return chunk; - } - }, - /** * contextDump helper * @param key specifies how much to dump. @@ -261,37 +249,6 @@ var helpers = { cond argument should evaluate to a valid javascript expression **/ - "if": function( chunk, context, bodies, params ) { - var body = bodies.block, - skip = bodies['else'], - cond; - - if(params && params.cond) { - // Will be removed in 1.6 - _deprecated("{@if}"); - - cond = dust.helpers.tap(params.cond, chunk, context); - // eval expressions with given dust references - if(eval(cond)){ - if(body) { - return chunk.render( bodies.block, context ); - } - else { - _log("Missing body block in the if helper!"); - return chunk; - } - } - if(skip){ - return chunk.render( bodies['else'], context ); - } - } - // no condition - else { - _log("No condition given in the if helper!"); - } - return chunk; - }, - /** * math helper * @param key is the value to perform math against diff --git a/test/jasmine-test/spec/helpersTests.js b/test/jasmine-test/spec/helpersTests.js index b45fa3a..a307cdc 100644 --- a/test/jasmine-test/spec/helpersTests.js +++ b/test/jasmine-test/spec/helpersTests.js @@ -13,60 +13,6 @@ } ] }, - { - name: "if", - tests: [ - { - name: "if helper with no body", - source: '{@if cond="{x}<{y}"/}', - context: { x: 2, y: 3 }, - expected: "", - message: "should test if helper with no body and fail gracefully" - }, - { - name: "if helper with no condition", - source: '{@if}Hello{/if}', - context: { x: 2, y: 3 }, - expected: "", - message: "should test if helper with no condition fails gracefully" - }, - { - name: "if helper without else", - source: '{@if cond="{x}<{y}"}
X < Y
{/if}', - context: { x: 2, y: 3 }, - expected: "
X < Y
", - message: "should test if helper without else" - }, - { - name: "if helper with else block", - source: '{@if cond=" \'{x}\'.length && \'{y}\'.length "}
X and Y exists
{:else}
X and Y does not exists
{/if}', - context: {}, - expected: "
X and Y does not exists
", - message: "should test if helper with else block" - }, - { - name: "if helper with else using the or condition", - source: '{@if cond=" \'{x}\'.length || \'{y}\'.length "}
X or Y exists
{:else}
X or Y does not exists
{/if}', - context: { x: 1}, - expected: "
X or Y exists
", - message: "should test if helper with else using the or condition" - }, - { - name: "if helper with else using the and conditon", - source: '{@if cond="( \'{x}\'.length ) && ({x}<3)"}
X exists and is 1
{:else}
x is not there
{/if}', - context: { x : 1}, - expected: "
X exists and is 1
", - message: "should test if helper with else usingt he and conditon" - }, - { - name: "if helper using $idx", - source: '{#list}{@if cond="( {$idx} == 1 )"}
{y}
{/if}{/list}', - context: { x : 1, list: [ { y: 'foo' }, { y: 'bar'} ]}, - expected: "
bar
", - message: "should test the if helper using $idx" - } - ] - }, { name: "math", tests: [ @@ -1488,25 +1434,6 @@ } ] }, - { - name: "idx", - tests: [ - { - name: "idx helper with no body", - source: '{#n}{@idx/}{.} {/n}', - context: { n: ["Mick", "Tom", "Bob"] }, - expected: "Mick Tom Bob ", - message: "idx helper with no body should not render" - }, - { - name: "idx helper within partial included in a array", - source: '{#n}{@idx}{.}>>{/idx}{>hello_there name=. count="30"/}{/n}', - context: { n: ["Mick", "Tom", "Bob"] }, - expected: "0>>Hello Mick! You have 30 new messages.1>>Hello Tom! You have 30 new messages.2>>Hello Bob! You have 30 new messages.", - message: "should test idx helper within partial included in a array" - } - ] - }, { name: "sep / first / last", tests: [