javascript - How do I stay DRY with Meteor template helpers function composition? -


i want remain dry templates created amazing composable functions , helpers realize spacebars doesn't play nicely.

i have 2 functions both take 2 arguments: func(a,b) in spacebars turns {{func b}}.

the goal compute func2(func1(a,b), c). figured spacebars @ functions , number of arguments each be able understand {{func2 func1 b c}}. doesn't seem case. ideas?

there's no such thing number of arguments in javascript. can define function no explicit arguments:

var f = function() {   return arguments[0] + arguments[1] + arguments[2]; }; 

and call how many arguments like:

f(1,2,3,4,5,6,7,8); 

since spacebars translated javascript, inherit behavior.

there's no simple way achieve want right now, sadly. you'd need more functions. easiest solution define func2reverse , call reversed order of arguments: {{func2reverse c func1 b}}


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -