\"+options.inverse(this)+\"
\"}};": { + !code: true + javascript: + ''' + function list(context, options) { + if (context.length > 0) { + var out = '' + options.inverse(this) + '
'; + } + } + ''' + php: + ''' + function($context, $options) { + $out = ''; + if (count($context) > 0) { + $out .= ''; + $out .= $options->inverse($options->scope); + $out .= '
'; + } + return $out; + } + ''' + } + "function(){return\"winning\"};": { + !code: true + javascript: + ''' + function () { + return 'winning'; + } + ''' + php: + ''' + function() { + return 'winning'; + } + ''' + } + "function(){return\"fail\"};": { + !code: true + javascript: function () { return 'fail'; } + php: function() { return 'fail'; } + } + "function(){return\"world\"};": { + !code: true + javascript: function () { return 'world'; } + php: function() { return 'world'; } + } + "function(){return\"helpers\"};": { + !code: true + javascript: function () { return 'helpers'; } + php: function() { return 'helpers'; } + } + "function(){return\"helper\"};": { + !code: true + javascript: function () { return 'helper'; } + php: function() { return 'helper'; } + } + "function(){return\"found it!\"};": { + !code: true + javascript: function () { return 'found it!'; } + php: function() { return 'found it!'; } + } + "function(){return\"world!\"};": { + !code: true + javascript: function () { return 'world!'; } + php: function() { return 'world!'; } + } + "function(times,times2){if(typeof times!==\"number\"){times=\"NaN\"}if(typeof times2!==\"number\"){times2=\"NaN\"}return\"Hello \"+times+\" \"+times2+\" times\"};": { + !code: true + javascript: + ''' + function (times, times2) { + if (typeof times !== 'number') { times = 'NaN'; } + if (typeof times2 !== 'number') { times2 = 'NaN'; } + return 'Hello ' + times + ' ' + times2 + ' times'; + } + ''' + php: + ''' + function($times, $times2) { + if (!is_numeric($times)) { + $times = 'NaN'; + } + if (!is_numeric($times2)) { + $times2 = "NaN"; + } + return "Hello $times $times2 times"; + } + ''' + } + "function(times){if(typeof times!==\"number\"){times=\"NaN\"}return\"Hello \"+times+\" times\"};": { + !code: true + javascript: + ''' + function (times) { + if (typeof times !== 'number') { times = 'NaN'; } + return 'Hello ' + times + ' times'; + } + ''' + php: + ''' + function($times) { + if(!is_numeric($times)) { + $times = "NaN"; + } + return "Hello $times times"; + } + ''' + } + "function(param,times,bool1,bool2){if(typeof times!==\"number\"){times=\"NaN\"}if(typeof bool1!==\"boolean\"){bool1=\"NaB\"}if(typeof bool2!==\"boolean\"){bool2=\"NaB\"}return\"Hello \"+param+\" \"+times+\" times: \"+bool1+\" \"+bool2};": { + !code: true + javascript: + ''' + function (param, times, bool1, bool2) { + if (typeof times !== 'number') { times = 'NaN'; } + if (typeof bool1 !== 'boolean') { bool1 = 'NaB'; } + if (typeof bool2 !== 'boolean') { bool2 = 'NaB'; } + return 'Hello ' + param + ' ' + times + ' times: ' + bool1 + ' ' + bool2; + } + ''' + php: + ''' + function($param, $times, $bool1, $bool2) { + if(!is_numeric($times)) { $times = "NaN"; } + if(!is_bool($bool1)) { + $bool1 = "NaB"; + } else { + $bool1 = ($bool1 ? 'true' : 'false'); + } + if(!is_bool($bool2)) { + $bool2 = "NaB"; + } else { + $bool2 = ($bool2 ? 'true' : 'false'); + } + + return "Hello $param $times times: $bool1 $bool2"; + } + ''' + } + "function(param){return\"Hello \"+param};": { + !code: true + javascript: function (param) { return 'Hello ' + param; } + php: function($param) { return "Hello " . $param; } + } + "function(cruel,world){return\"Goodbye \"+cruel+\" \"+world};": { + !code: true + javascript: function (cruel, world) { return 'Goodbye ' + cruel + ' ' + world; } + php: function($cruel, $world) { return 'Goodbye ' . $cruel . ' ' . $world; } + } + "function(cruel,world,options){return options.fn({greeting:\"Goodbye\",adj:cruel,noun:world})};": { + !code: true + javascript: + ''' + function (cruel, world, options) { + return options.fn({greeting: 'Goodbye', adj: cruel, noun: world}); + } + ''' + php: + ''' + function($cruel, $world, $options) { + return $options->fn(array('greeting' => 'Goodbye', 'adj' => 'cruel', 'noun' => 'world')); + } + ''' + } + "function(options){return\"GOODBYE \"+options.hash.cruel+\" \"+options.hash.world+\" \"+options.hash.times+\" TIMES\"};": { + !code: true + javascript: + ''' + function (options) { + return 'GOODBYE ' + options.hash.cruel + ' ' + options.hash.world + ' ' + options.hash.times + ' TIMES'; + } + ''' + php: + ''' + function($options) { + $r = 'GOODBYE '; + $r .= $options['hash']['cruel'].' '; + $r .= $options['hash']['world'].' '; + $r .= $options['hash']['times'].' TIMES'; + + return $r; + } + ''' + } + "function goodbye(options){if(options.hash.print===true){return\"GOODBYE \"+options.hash.cruel+\" \"+options.hash.world}else if(options.hash.print===false){return\"NOT PRINTING\"}else{return\"THIS SHOULD NOT HAPPEN\"}};": { + !code: true + javascript: + ''' + function goodbye(options) { + if (options.hash.print === true) { + return 'GOODBYE ' + options.hash.cruel + ' ' + options.hash.world; + } else if (options.hash.print === false) { + return 'NOT PRINTING'; + } else { + return 'THIS SHOULD NOT HAPPEN'; + } + } + ''' + php: + ''' + function ($options) { + if ($options['hash']['print'] === true) { + return 'GOODBYE ' . $options['hash']['cruel'] . ' ' . $options['hash']['world']; + } else if ($options['hash']['print'] === false) { + return 'NOT PRINTING'; + } else { + return 'THIS SHOULD NOT HAPPEN'; + } + } + ''' + } + "function(options){return\"GOODBYE \"+options.hash.cruel+\" \"+options.fn(this)+\" \"+options.hash.times+\" TIMES\"};": { + !code: true + javascript: + ''' + function (options) { + return 'GOODBYE ' + options.hash.cruel + ' ' + options.fn(this) + ' ' + options.hash.times + ' TIMES'; + } + ''' + php: + ''' + function($options) { + return "GOODBYE {$options['hash']['cruel']} " . $options->fn($options->scope) . " {$options['hash']['times']} TIMES"; + } + ''' + } + "function goodbye(options){if(options.hash.print===true){return\"GOODBYE \"+options.hash.cruel+\" \"+options.fn(this)}else if(options.hash.print===false){return\"NOT PRINTING\"}else{return\"THIS SHOULD NOT HAPPEN\"}};": { + !code: true + javascript: + ''' + function goodbye(options) { + if (options.hash.print === true) { + return 'GOODBYE ' + options.hash.cruel + ' ' + options.fn(this); + } else if (options.hash.print === false) { + return 'NOT PRINTING'; + } else { + return 'THIS SHOULD NOT HAPPEN'; + } + } + ''' + php: + ''' + function ($options) { + if ($options['hash']['print'] === true) { + return 'GOODBYE ' . $options['hash']['cruel'] . ' ' . $options->fn($options->scope); + } else if ($options['hash']['print'] === false) { + return 'NOT PRINTING'; + } else { + return 'THIS SHOULD NOT HAPPEN'; + } + } + ''' + } + "function(mesg,options){if(options.name===\"link_to\"){return new Handlebars.SafeString(\"\"+mesg+\"\")}};": { + !code: true + javascript: + ''' + function (mesg, options) { + if (options.name === 'link_to') { + return new Handlebars.SafeString('' + mesg + ''); + } + } + ''' + php: + ''' + function($mesg, $options = null) { + if($options && $options['name'] === "link_to") { + return new SafeString("" . $mesg . ""); + } + } + ''' + } + "function(options){if(options.name===\"link_to\"){return new Handlebars.SafeString(\"winning\")}};": { + !code: true + javascript: + ''' + function (options) { + if (options.name === 'link_to') { + return new Handlebars.SafeString('winning'); + } + } + ''' + php: + ''' + function($options) { + if($options['name'] === "link_to") { + return new SafeString("winning"); + } + } + ''' + } + "function(){return\"foo\"};": { + !code: true + javascript: + ''' + function () { + return 'foo'; + } + ''' + php: + ''' + function() { + return 'foo'; + } + ''' + } + "function(arg){return typeof arg};": { + !code: true + javascript: function (arg) { return typeof arg; } + php: function($arg) { return $arg === null ? 'undefined' : gettype($arg); } + } + "function(){return this.bar};": { + !code: true + javascript: function () { return this.bar; } + php: function($context) { return $context['bar']; } + } + "function(){return this.truthiness()};": { + !code: true + javascript: function () { return this.truthiness(); } + php: function($options) { return $options->scope['truthiness'](); } + } + "function(){return\"missing: \"+arguments[arguments.length-1].name};": { + !code: true + javascript: + ''' + function () { + return 'missing: ' + arguments[arguments.length - 1].name; + } + ''' + php: + ''' + function() { + $arguments = func_get_args(); + return 'missing: ' . $arguments[count($arguments)-1]['name']; + } + ''' + } + "function(){return\"helper missing: \"+arguments[arguments.length-1].name};": { + !code: true + javascript: + ''' + function () { + return 'helper missing: ' + arguments[arguments.length - 1].name; + } + ''' + php: + ''' + function() { + $arguments = func_get_args(); + return 'helper missing: ' . $arguments[count($arguments)-1]['name']; + } + ''' + } + "function(){return\"ran: \"+arguments[arguments.length-1].name};": { + !code: true + javascript: + ''' + function () { + return 'ran: ' + arguments[arguments.length - 1].name; + } + ''' + php: + ''' + function() { + $arguments = func_get_args(); + return 'ran: ' . $arguments[count($arguments)-1]['name']; + } + ''' + } + "function(){return this.goodbye.toUpperCase()};": { + !code: true + javascript: + ''' + function () { + return this.goodbye.toUpperCase(); + } + ''' + php: + ''' + function($options) { + return strtoupper($options->scope['goodbye']); + } + ''' + } + "function(world){return\"cruel \"+world.toUpperCase()};": { + !code: true + javascript: + ''' + function (world) { + return 'cruel ' + world.toUpperCase(); + } + ''' + php: + ''' + function($world) { + return "cruel " . strtoupper($world); + } + ''' + } + "function(options){return this.goodbye.toUpperCase()+options.fn(this)};": { + !code: true + javascript: + ''' + function (options) { + return this.goodbye.toUpperCase() + options.fn(this); + } + ''' + php: + ''' + function($options) { + return strtoupper($options->scope['goodbye']) . $options->fn($options->scope); + } + ''' + } + "function(options){equals(options.fn.blockParams,1);return options.fn({value:\"bar\"},{blockParams:[1,2]})};": { + !code: true + javascript: + ''' + function (options) { + equals(options.fn.blockParams, 1); + return options.fn({value: 'bar'}, {blockParams: [1, 2]}); + } + ''' + php: + ''' + function($options) { + return $options->fn(array('value' => 'bar'), array('blockParams' => array(1, 2))); + } + ''' + } + "function(options){equals(options.fn.blockParams,1);return options.fn({},{blockParams:[1,2]})};": { + !code: true + javascript: + ''' + function (options) { + equals(options.fn.blockParams, 1); + return options.fn({}, {blockParams: [1, 2]}); + } + ''' + php: + ''' + function($options) { + return $options->fn(array(), array('blockParams' => array(1, 2))); + } + ''' + } + "function(options){equals(options.fn.blockParams,1);return options.fn(this,{blockParams:[1,2]})};": { + !code: true + javascript: + ''' + function (options) { + equals(options.fn.blockParams, 1); + return options.fn(this, {blockParams: [1, 2]}); + } + ''' + php: + ''' + function($options) { + return $options->fn($options->scope, array('blockParams' => array(1, 2))); + } + ''' + } + "function(options){if(typeof value===\"undefined\"){value=1}return options.fn({value:\"bar\"},{blockParams:options.fn.blockParams===1?[global.value++,global.value++]:undefined})};": { + !code: true + javascript: + ''' + function (options) { + if( typeof value === 'undefined' ) { value = 1; } return options.fn({value: 'bar'}, {blockParams: options.fn.blockParams === 1 ? [global.value++, global.value++] : undefined}); + } + ''' + } + "function testHelper(options){return options.lookupProperty(this,\"testProperty\")};": { + !code: true + javascript: + ''' + function testHelper(options) { + return options.lookupProperty(this, 'testProperty'); + } + ''' + php: + ''' + function ($options) { + return $options->lookupProperty($options->scope, 'testProperty'); + } + ''' + } + "function(){return\"dude\"};": { + !code: true + javascript: + ''' + function () { + return 'dude'; + } + ''' + php: + ''' + function() { + return 'dude'; + } + ''' + } + "function(){return\"missing\"};": { + !code: true + javascript: + ''' + function () { + return 'missing'; + } + ''' + php: + ''' + function() { + return 'missing'; + } + ''' + } + "function partial(context){return context.name+\" (\"+context.url+\") \"};": { + !code: true + javascript: + ''' + function partial(context) { + return context.name + ' (' + context.url + ') '; + } + ''' + php: + ''' + function($context) { + return $context['name'] . ' (' . $context['url'] . ') '; + } + ''' + } + "function(){return\"blah\"};": { + !code: true + javascript: + ''' + function () { + return 'blah'; + } + ''' + php: + ''' + function() { + return "blah"; + } + ''' + } + "function(block){return block.fn(\"\")};": { + !code: true + javascript: function (block) { return block.fn(''); } + php: function($block) { return $block/*['fn']*/->fn(''); } + } + "function(block){return block.inverse(\"\")};": { + !code: true + javascript: function (block) { return block.inverse(''); } + php: function($block) { return $block/*['inverse']*/->inverse(''); } + } + "function(value){return value+\"\"};": { + !code: true + javascript: function (value) { return value + ''; } + php: function($value) { return $value === null ? 'undefined' : (string) $value; } + } + "function(options){return new Handlebars.SafeString(options.fn())};": { + !code: true + javascript: + ''' + function (options) { + return new Handlebars.SafeString(options.fn()); + } + ''' + php: + ''' + function($options) { + return new \Handlebars\SafeString($options->fn()); + } + ''' + } + "function(){for(var name in this){if(Object.prototype.hasOwnProperty.call(this,name)){return\"found\"}}return this===\"bat\"?\"found\":\"not\"};": { + !code: true + javascript: + ''' + function() { + // It's valid to execute a block against an undefined context, but + // helpers can not do so, so we expect to have an empty object here; + for (var name in this) { + if (Object.prototype.hasOwnProperty.call(this, name)) { + return 'found'; + } + } + // And to make IE happy, check for the known string as length is not enumerated. + return this === 'bat' ? 'found' : 'not'; + } + ''' + php: + ''' + function() { + return 'found'; + } + ''' + } + "function(conditional,options){if(conditional){return options.fn(this)}else{return options.inverse(this)}};": { + !code: true + javascript: + ''' + function(conditional, options) { + if (conditional) { + return options.fn(this); + } else { + return options.inverse(this); + } + } + ''' + php: + ''' + function($conditional, $options) { + if ($conditional) { + return $options->fn($options->scope); + } else { + return $options->inverse($options->scope); + } + } + ''' + } + "function(options){return options.hash.length};": { + !code: true + javascript: + ''' + function(options) { + return options.hash.length; + } + ''' + php: + ''' + function($options) { + return $options['hash']['length']; + } + ''' + } + "function(options){equals(\"value\"in options.hash,true);equals(options.hash.value,undefined);return\"success\"};": { + !code: true + javascript: + ''' + function (options) { + equals('value' in options.hash, true); + equals(options.hash.value, undefined); + return 'success'; + } + ''' + php: + ''' + function () { + return 'success'; + } + ''' + } + "function(passiveVoice,noun){return\"HELP ME MY BOSS \"+passiveVoice+\" \"+noun};": { + !code: true + javascript: + ''' + function (passiveVoice, noun) { + return 'HELP ME MY BOSS ' + passiveVoice + ' ' + noun; + } + ''' + php: + ''' + function($passiveVoice, $noun) { + return "HELP ME MY BOSS " . $passiveVoice . ' ' . $noun; + } + ''' + } + "function(passiveVoice,noun,options){return\"HELP ME MY BOSS \"+passiveVoice+\" \"+noun+\": \"+options.fn(this)};": { + !code: true + javascript: + ''' + function (passiveVoice, noun, options) { + return 'HELP ME MY BOSS ' + passiveVoice + ' ' + + noun + ': ' + options.fn(this); + } + ''' + php: + ''' + function($passiveVoice, $noun, $options) { + return "HELP ME MY BOSS " . $passiveVoice . ' ' . + $noun . ': ' . $options->fn($options->scope); + } + ''' + } + "function(desire,noun,options){return\"STOP ME FROM READING HACKER NEWS I \"+options.contexts[0][desire]+\" \"+noun};": { + !code: true + javascript: + ''' + function (desire, noun, options) { + return 'STOP ME FROM READING HACKER NEWS I ' + + options.contexts[0][desire] + ' ' + noun; + } + ''' + php: + ''' + function($desire, $noun, $options) { + return "STOP ME FROM READING HACKER NEWS I " . + $options['contexts'][0][$desire] . " " . $noun; + } + ''' + } + "function(context,options){return options.fn(options.contexts[0][context])};": { + !code: true + javascript: + ''' + function (context, options) { + return options.fn(options.contexts[0][context]); + } + ''' + php: + ''' + function($context, $options) { + return $options->fn($options['contexts'][0][$context]); + } + ''' + } + "function(desire,noun,trueBool,falseBool,options){equal(options.types[0],\"StringLiteral\",\"the string type is passed\");equal(options.types[1],\"PathExpression\",\"the expression type is passed\");equal(options.types[2],\"BooleanLiteral\",\"the expression type is passed\");equal(desire,\"need\",\"the string form is passed for strings\");equal(noun,\"dad.joke\",\"the string form is passed for expressions\");equal(trueBool,true,\"raw booleans are passed through\");equal(falseBool,false,\"raw booleans are passed through\");return\"Helper called\"};": { + !code: true + javascript: + ''' + function(desire, noun, trueBool, falseBool, options) { + equal(options.types[0], 'StringLiteral', 'the string type is passed'); + equal( + options.types[1], + 'PathExpression', + 'the expression type is passed' + ); + equal( + options.types[2], + 'BooleanLiteral', + 'the expression type is passed' + ); + equal(desire, 'need', 'the string form is passed for strings'); + equal(noun, 'dad.joke', 'the string form is passed for expressions'); + equal(trueBool, true, 'raw booleans are passed through'); + equal(falseBool, false, 'raw booleans are passed through'); + return 'Helper called'; + } + ''' + } + "function(exclamation,options){equal(exclamation,\"he.says\");equal(options.types[0],\"PathExpression\");equal(options.hashTypes.desire,\"StringLiteral\");equal(options.hashTypes.noun,\"PathExpression\");equal(options.hashTypes.bool,\"BooleanLiteral\");equal(options.hash.desire,\"need\");equal(options.hash.noun,\"dad.joke\");equal(options.hash.bool,true);return\"Helper called\"};": { + !code: true + javascript: + ''' + function(exclamation, options) { + equal(exclamation, 'he.says'); + equal(options.types[0], 'PathExpression'); + + equal(options.hashTypes.desire, 'StringLiteral'); + equal(options.hashTypes.noun, 'PathExpression'); + equal(options.hashTypes.bool, 'BooleanLiteral'); + equal(options.hash.desire, 'need'); + equal(options.hash.noun, 'dad.joke'); + equal(options.hash.bool, true); + return 'Helper called'; + } + ''' + } + "function(desire,noun,options){return\"STOP ME FROM READING HACKER NEWS I \"+options.contexts[0][desire]+\" \"+noun+\" \"+options.fn(this)};": { + !code: true + javascript: + ''' + function (desire, noun, options) { + return 'STOP ME FROM READING HACKER NEWS I ' + + options.contexts[0][desire] + ' ' + noun + ' ' + + options.fn(this); + } + ''' + php: + ''' + function($desire, $noun, $options) { + return "STOP ME FROM READING HACKER NEWS I " . + $options['contexts'][0][$desire] . " " . $noun . " " . + $options->fn($options->scope); + } + ''' + } + "function(){return\"WITH\"};": { + !code: true + javascript: + ''' + function () { + return 'WITH'; + } + ''' + php: + ''' + function($options) { + return "WITH"; + } + ''' + } + "function(){return\"VIEW\"};": { + !code: true + javascript: + ''' + function () { + return 'VIEW'; + } + ''' + php: + ''' + function() { + return "VIEW"; + } + ''' + } + "function(bar,options){equal(bar,\"@bar\");equal(options.types[0],\"PathExpression\");return\"Foo!\"};": { + !code: true + javascript: + ''' + function (bar, options) { + equal(bar, '@bar'); + equal(options.types[0], 'PathExpression'); + return 'Foo!'; + } + ''' + php: + ''' + function($bar, $options) { + return 'Foo!'; + } + ''' + } + "function(val){return val+val};": { + !code: true + javascript: + ''' + function (val) { + return val + val; + } + ''' + php: + ''' + function($val) { + return $val . $val; + } + ''' + } + "function(){return\"LOL\"};": { + !code: true + javascript: + ''' + function () { + return 'LOL'; + } + ''' + php: + ''' + function() { + return "LOL"; + } + ''' + } + "function(val){return\"val is \"+val};": { + !code: true + javascript: + ''' + function (val) { + return 'val is ' + val; + } + ''' + php: + ''' + function($val) { + return "val is " . (is_bool($val) ? ($val ? 'true' : 'false') : $val); + } + ''' + } + "function(x,y){return x===y};": { + !code: true + javascript: + ''' + function (x, y) { + return x === y; + } + ''' + php: + ''' + function($x, $y) { + return $x === $y; + } + ''' + } + "function(val,that,theOther){return\"val is \"+val+\", \"+that+\" and \"+theOther};": { + !code: true + javascript: + ''' + function (val, that, theOther) { + return 'val is ' + val + ', ' + that + ' and ' + theOther; + } + ''' + php: + ''' + function($val, $that, $theOther) { + return "val is " . $val . ', ' . (is_bool($that) ? ($that ? 'true' : 'false') : $that) . ' and ' . $theOther; + } + ''' + } + "function(a,b){return a+\"-\"+b};": { + !code: true + javascript: + ''' + function (a, b) { + return a + '-' + b; + } + ''' + php: + ''' + function($a, $b) { + return $a . "-" . $b; + } + ''' + } + "function(a,b){return a+b};": { + !code: true + javascript: + ''' + function (a, b) { + return a + b; + } + ''' + php: + ''' + function($a, $b) { + return $a . $b; + } + ''' + } + "function(x,y,options){if(!options||options===global.lastOptions){throw new Error(\"options hash was reused\")}global.lastOptions=options;return x===y};": { + !code: true + javascript: + ''' + function(x, y, options) { + if (!options || options === global.lastOptions) { + throw new Error('options hash was reused'); + } + global.lastOptions = options; + return x === y; + } + ''' + } + "function(options){return\"val is \"+options.hash.fun};": { + !code: true + javascript: + ''' + function (options) { + return "val is " + options.hash.fun; + } + ''' + php: + ''' + function($options) { + return "val is " . (is_bool($tmp = $options['hash']['fun']) ? ($tmp ? 'true' : 'false') : $tmp); + } + ''' + } + "function(options){var hash=options.hash;var ariaLabel=Handlebars.Utils.escapeExpression(hash[\"aria-label\"]);var placeholder=Handlebars.Utils.escapeExpression(hash.placeholder);return new Handlebars.SafeString('')};": { + !code: true + javascript: + ''' + function (options) { + var hash = options.hash; + var ariaLabel = Handlebars.Utils.escapeExpression(hash['aria-label']); + var placeholder = Handlebars.Utils.escapeExpression(hash.placeholder); + return new Handlebars.SafeString(''); + } + ''' + php: + ''' + function($options) { + $hash = $options['hash']; + $ariaLabel = (string) ($hash['aria-label'] instanceof SafeString ? $hash['aria-label'] : htmlspecialchars($hash['aria-label'])); + $placeholder = (string) ($hash['placeholder'] instanceof SafeString ? $hash['placeholder'] : htmlspecialchars($hash['placeholder'])); + return new SafeString(''); + } + ''' + } + "function(defaultString){return new Handlebars.SafeString(defaultString)};": { + !code: true + javascript: + ''' + function (defaultString) { + return new Handlebars.SafeString(defaultString); + } + ''' + php: + ''' + function($defaultString) { + return new SafeString($defaultString); + } + ''' + } + "function(a,b,options){equals(a,\"foo\");equals(options.types.length,2,\"string params for outer helper processed correctly\");equals(options.types[0],\"SubExpression\",\"string params for outer helper processed correctly\");equals(options.types[1],\"PathExpression\",\"string params for outer helper processed correctly\");return a+b};": { + !code: true + javascript: + ''' + function (a, b, options) { + equals(a, 'foo'); + equals(options.types.length, 2, 'string params for outer helper processed correctly'); + equals(options.types[0], 'SubExpression', 'string params for outer helper processed correctly'); + equals(options.types[1], 'PathExpression', 'string params for outer helper processed correctly'); + return a + b; + } + ''' + php: + ''' + function($a, $b, $options) { + return $a . $b; + } + ''' + } + "function(a,options){equals(options.types.length,1,\"string params for inner helper processed correctly\");equals(options.types[0],\"PathExpression\",\"string params for inner helper processed correctly\");return a};": { + !code: true + javascript: + ''' + function (a, options) { + equals(options.types.length, 1, 'string params for inner helper processed correctly'); + equals(options.types[0], 'PathExpression', 'string params for inner helper processed correctly'); + return a; + } + ''' + php: + ''' + function($a, $options) { + return $a; + } + ''' + } + "function(options){equals(options.hashTypes.fun,\"SubExpression\");return\"val is \"+options.hash.fun};": { + !code: true + javascript: + ''' + function(options) { + equals(options.hashTypes.fun, 'SubExpression'); + return 'val is ' + options.hash.fun; + } + ''' + } + "function(){return\"BORK\"};": { + !code: true + javascript: + ''' + function () { + return 'BORK'; + } + ''' + php: + ''' + function() { + return "BORK"; + } + ''' + } + "function(passiveVoice,noun,options){equal(options.ids,undefined);equal(options.hashIds,undefined);return\"success\"};": { + !code: true + javascript: + ''' + function (passiveVoice, noun, options) { + equal(options.ids, undefined); + equal(options.hashIds, undefined); + + return 'success'; + } + ''' + php: + ''' + function($passiveVoice, $noun, $options) { + return 'success'; + } + ''' + } + "function(passiveVoice,noun,options){equal(options.ids[0],\"is.a\");equal(options.ids[1],\"slave.driver\");return\"HELP ME MY BOSS \"+options.ids[0]+\":\"+passiveVoice+\" \"+options.ids[1]+\":\"+noun};": { + !code: true + javascript: + ''' + function (passiveVoice, noun, options) { + equal(options.ids[0], 'is.a'); + equal(options.ids[1], 'slave.driver'); + + return 'HELP ME MY BOSS ' + options.ids[0] + ':' + passiveVoice + ' ' + options.ids[1] + ':' + noun; + } + ''' + php: + ''' + function($passiveVoice, $noun, $options) { + return "HELP ME MY BOSS " . $options['ids'][0] . ':' . $passiveVoice . ' ' . $options['ids'][1] . ':' . $noun; + } + ''' + } + "function(options){equal(options.hashIds.bat,\"is.a\");equal(options.hashIds.baz,\"slave.driver\");return\"HELP ME MY BOSS \"+options.hashIds.bat+\":\"+options.hash.bat+\" \"+options.hashIds.baz+\":\"+options.hash.baz};": { + !code: true + javascript: + ''' + function (options) { + equal(options.hashIds.bat, 'is.a'); + equal(options.hashIds.baz, 'slave.driver'); + + return 'HELP ME MY BOSS ' + options.hashIds.bat + ':' + options.hash.bat + ' ' + options.hashIds.baz + ':' + options.hash.baz; + } + ''' + php: + ''' + function($options) { + return "HELP ME MY BOSS " . $options['hashIds']['bat'] . ':' . $options['hash']['bat'] . ' ' . $options['hashIds']['baz'] . ':' . $options['hash']['baz']; + } + ''' + } + "function(passiveVoice,noun,thiz,thiz2,options){equal(options.ids[0],\"is.a\");equal(options.ids[1],\"../slave.driver\");equal(options.ids[2],\"is.a\");equal(options.ids[3],\"\");return\"HELP ME MY BOSS \"+options.ids[0]+\":\"+passiveVoice+\" \"+options.ids[1]+\":\"+noun};": { + !code: true + javascript: + ''' + function (passiveVoice, noun, thiz, thiz2, options) { + equal(options.ids[0], 'is.a'); + equal(options.ids[1], '../slave.driver'); + equal(options.ids[2], 'is.a'); + equal(options.ids[3], ''); + + return 'HELP ME MY BOSS ' + options.ids[0] + ':' + passiveVoice + ' ' + options.ids[1] + ':' + noun; + } + ''' + php: + ''' + function($passiveVoice, $noun, $thiz, $thiz2, $options) { + return "HELP ME MY BOSS " . $options['ids'][0] . ':' . $passiveVoice . ' ' . $options['ids'][1] . ':' . ($noun === null ? 'undefined' : $noun); + } + ''' + } + "function(passiveVoice,noun,options){equal(options.ids[0],\"@is.a\");equal(options.ids[1],\"@slave.driver\");return\"HELP ME MY BOSS \"+options.ids[0]+\":\"+passiveVoice+\" \"+options.ids[1]+\":\"+noun};": { + !code: true + javascript: + ''' + function (passiveVoice, noun, options) { + equal(options.ids[0], '@is.a'); + equal(options.ids[1], '@slave.driver'); + + return 'HELP ME MY BOSS ' + options.ids[0] + ':' + passiveVoice + ' ' + options.ids[1] + ':' + noun; + } + ''' + php: + ''' + function($passiveVoice, $noun, $options) { + return "HELP ME MY BOSS " . $options['ids'][0] . ':' . $passiveVoice . ' ' . $options['ids'][1] . ':' . $noun; + } + ''' + } + "function(passiveVoice,noun,options){equal(options.ids[0],null);equal(options.ids[1],null);equal(options.hashIds.key,null);return\"HELP ME MY BOSS \"+passiveVoice+\" \"+noun+\" \"+options.hash.key};": { + !code: true + javascript: + ''' + function (passiveVoice, noun, options) { + equal(options.ids[0], null); + equal(options.ids[1], null); + equal(options.hashIds.key, null); + + return 'HELP ME MY BOSS ' + passiveVoice + ' ' + noun + ' ' + options.hash.key; + } + ''' + php: + ''' + function($passiveVoice, $noun, $options) { + return "HELP ME MY BOSS " . $passiveVoice . ' ' . $noun . ' ' . ($options['hash']['key'] === false ? 'false' : $options['hash']['key']); + } + ''' + } + "function(){return 1};": { + !code: true + javascript: function () { return 1; } + php: function() { return 1; } + } + "function(passiveVoice,options){equal(options.ids[0],true);return\"HELP ME MY BOSS \"+passiveVoice};": { + !code: true + javascript: + ''' + function (passiveVoice, options) { + equal(options.ids[0], true); + + return 'HELP ME MY BOSS ' + passiveVoice; + } + ''' + php: + ''' + function($passiveVoice, $options) { + return "HELP ME MY BOSS " . $passiveVoice; + } + ''' + } + "function(options){var blockParams=[this.is];blockParams.path=[\"zomg\"];return options.fn(this,{blockParams:blockParams})};": { + !code: true + javascript: + ''' + function (options) { + var blockParams = [this.is]; + blockParams.path = ['zomg']; + return options.fn(this, {blockParams: blockParams}); + } + ''' + php: + ''' + function($options) { + $blockParams = array($options->scope['is']); + $blockParams['path'] = array('zomg'); + return $options->fn($options->scope, array('blockParams' => $blockParams)); + } + ''' + } + "function(passiveVoice,noun,blah,options){equal(options.ids[0],\"zomg.a\");equal(options.ids[1],\"slave.driver\");equal(options.ids[2],\"zomg\");return\"HELP ME MY BOSS \"+options.ids[0]+\":\"+passiveVoice+\" \"+options.ids[1]+\":\"+noun};": { + !code: true + javascript: + ''' + function (passiveVoice, noun, blah, options) { + equal(options.ids[0], 'zomg.a'); + equal(options.ids[1], 'slave.driver'); + equal(options.ids[2], 'zomg'); + + return 'HELP ME MY BOSS ' + options.ids[0] + ':' + passiveVoice + ' ' + options.ids[1] + ':' + noun; + } + ''' + php: + ''' + function($passiveVoice, $noun, $blah, $options) { + return 'HELP ME MY BOSS ' . $options->ids[0] . ':' . $passiveVoice . ' ' . $options->ids[1] . ':' . $noun; + } + ''' + } + "function(name,options){return name+\":\"+options.ids[0]+\"\\n\"};": { + !code: true + javascript: + ''' + function (name, options) { + return name + ':' + options.ids[0] + '\n'; + } + ''' + php: + ''' + function($name, $options) { + return $name . ':' . $options->ids[0] . "\n"; + } + ''' + } + "function(name,options){return name+\":\"+options.data.contextPath+\"\\n\"};": { + !code: true + javascript: + ''' + function (name, options) { + return name + ':' + options.data.contextPath + '\n'; + } + ''' + php: + ''' + function($name, $options) { + return $name . ':' . $options['data']['contextPath'] . "\n"; + } + ''' + } + "function(fn,props,container,options){equals(options.args[0],undefined);run=true;return fn};": { + !code: true + javascript: + ''' + function(fn, props, container, options) { + equals(options.args[0], undefined); + run = true; + return fn; + } + ''' + } + "function(context,options){var inverse=options.inverse,fn=options.fn;if(context===true){return fn(this)}else if(context===false||context==null){return inverse(this)}else if(_utils.isArray(context)){if(context.length>0){if(options.ids){options.ids=[options.name]}return instance.helpers.each(context,options)}else{return inverse(this)}}else{if(options.data&&options.ids){var data=_utils.createFrame(options.data);data.contextPath=_utils.appendContextPath(options.data.contextPath,options.name);options={data:data}}return fn(context,options)}};": { + !code: true + javascript: + ''' + function (context, options) { + var inverse = options.inverse, + fn = options.fn; + + if (context === true) { + return fn(this); + } else if (context === false || context == null) { + return inverse(this); + } else if (_utils.isArray(context)) { + if (context.length > 0) { + if (options.ids) { + options.ids = [options.name]; + } + + return instance.helpers.each(context, options); + } else { + return inverse(this); + } + } else { + if (options.data && options.ids) { + var data = _utils.createFrame(options.data); + data.contextPath = _utils.appendContextPath(options.data.contextPath, options.name); + options = { data: data }; + } + + return fn(context, options); + } + } + ''' + } + "function(context,options){if(!options){throw new _exception2[\"default\"](\"Must pass iterator to #each\")}var fn=options.fn,inverse=options.inverse,i=0,ret=\"\",data=undefined,contextPath=undefined;if(options.data&&options.ids){contextPath=_utils.appendContextPath(options.data.contextPath,options.ids[0])+\".\"}if(_utils.isFunction(context)){context=context.call(this)}if(options.data){data=_utils.createFrame(options.data)}function execIteration(field,index,last){if(data){data.key=field;data.index=index;data.first=index===0;data.last=!!last;if(contextPath){data.contextPath=contextPath+field}}ret=ret+fn(context[field],{data:data,blockParams:_utils.blockParams([context[field],field],[contextPath+field,null])})}if(context&&typeof context===\"object\"){if(_utils.isArray(context)){for(var j=context.length;i';\n $out .= $options->inverse($options->scope);\n $out .= '<\/p>';\n }\n return $out;\n}" - } - } - }, - "helpers-block helper inverted sections-01": { - "helpers": { - "list": { - "php": "function($context, $options) {\n $out = '';\n if (count($context) > 0) {\n $out .= '
';\n $out .= $options->inverse($options->scope);\n $out .= '<\/p>';\n }\n return $out;\n}" - } - } - }, - "helpers-block helper inverted sections-02": { - "helpers": { - "list": { - "php": "function($context, $options) {\n $out = '';\n if (count($context) > 0) {\n $out .= '
';\n $out .= $options->inverse($options->scope);\n $out .= '<\/p>';\n }\n return $out;\n}" - } - } - }, - "helpers-block helper passing a complex path context-00": { - "helpers": { - "form": { - "php": "function($context, $options) {\n return '