Bläddra i källkod

Pipeline with recursive search. To take a function with parent

pull/691/head
Kieling 7 år sedan
förälder
incheckning
a5920c37b3
7 ändrade filer med 35 tillägg och 10 borttagningar
  1. +9
    -6
      mustache.js
  2. +1
    -1
      mustache.min.js
  3. +3
    -3
      package.json
  4. +1
    -0
      test/_files/cli_output.txt
  5. +9
    -0
      test/_files/pipeline.js
  6. +7
    -0
      test/_files/pipeline.mustache
  7. +5
    -0
      test/_files/pipeline.txt

+ 9
- 6
mustache.js Visa fil

@@ -383,13 +383,16 @@
Context.prototype.resolvePipelineOperator = function resolvePipelineOperator (value, pipelines){
var self = this;
var pipelineResolver = function pipelineResolver (val, func){
if (self.view.hasOwnProperty(func)){
return self.view[func](val);
} else if (self.parent && self.parent.view.hasOwnProperty(func)){
return self.parent.view[func](val);
} else {
return val;
var findFunction = function(instance, functionToFind, valueToPutInFindedFunction, depth){
if(depth <= 0 || !instance) return null;
if(instance.view.hasOwnProperty(functionToFind)) return instance.view[func](valueToPutInFindedFunction);

return findFunction(instance.parent, functionToFind, val, depth)
}

var findedFunction = findFunction(self, func, val, 20)

return findedFunction ? findedFunction : val
};
return pipelines.reduce(pipelineResolver,value);
};


+ 1
- 1
mustache.min.js
Filskillnaden har hållits tillbaka eftersom den är för stor
Visa fil


+ 3
- 3
package.json Visa fil

@@ -1,6 +1,6 @@
{
"name": "mustache",
"version": "3.0.1",
"name": "terun-mustache",
"version": "3.0.3",
"description": "Logic-less {{mustache}} templates with JavaScript",
"author": "mustache.js Authors <http://github.com/janl/mustache.js>",
"homepage": "https://github.com/janl/mustache.js",
@@ -44,7 +44,7 @@
"eslint": "2.5.1",
"jshint": "^2.9.5",
"mocha": "^3.0.2",
"uglify-js": "^3.4.6",
"uglify-js": "^3.4.6"
"zuul": "^3.11.0",
"zuul-ngrok": "nolanlawson/zuul-ngrok#patch-1"
},


+ 1
- 0
test/_files/cli_output.txt Visa fil

@@ -0,0 +1 @@
Howdy LeBron, CLI rox

+ 9
- 0
test/_files/pipeline.js Visa fil

@@ -3,6 +3,15 @@
job: {
name: 'Developer'
},
attributes:[
{
name: 'good',
options: [
'outgoing',
'shy'
]
}
],
numbers:[1,2,3],
sumOne:(value)=>{
return value + 1;


+ 7
- 0
test/_files/pipeline.mustache Visa fil

@@ -48,3 +48,10 @@
{{#numbers}}
{{. |> sumOne |> setNameFuncion |> lower}}
{{/numbers}}
-- Level Array
{{#attributes}}
{{#options}}
{{name |> upper}}
{{. |> upper}}
{{/options}}
{{/attributes}}

+ 5
- 0
test/_files/pipeline.txt Visa fil

@@ -48,3 +48,8 @@ Developer
2: this is a value
3: this is a value
4: this is a value
-- Level Array
GOOD
OUTGOING
GOOD
SHY

Laddar…
Avbryt
Spara