soma-template icon indicating copy to clipboard operation
soma-template copied to clipboard

Parse functions in parameters

Open uiii opened this issue 11 years ago • 1 comments

When an interpolation token is used as a helper (scope function), allow parameters to be helper/function calls too.

E.g.

<div data-show="{{and(isFirst($index), infoIsDefined)}}">
    {{upperCase(replace(" ", "-", info))}}
</div>

uiii avatar Jun 18 '13 19:06 uiii

So There's a "issue-5" branch where I've enabled parsing function in parameters.

It works, however the regex to extract the params is a lot more complex.

https://github.com/soundstep/soma-template/blob/issue-5/src/2.settings.js#L76 versus https://github.com/soundstep/soma-template/blob/master/src/2.settings.js#L75

That makes the lib slightly slower, even if you don't it as this regex is used constantly.

Master benchmarks:

  • render text node x 23,706 ops/sec ±1.77% (74 runs sampled)

Issue-5 benchmarks:

  • render text node x 21,470 ops/sec ±1.76% (90 runs sampled)

Benchmarks are on the repo: https://github.com/soundstep/soma-template/tree/master/benchmarks

I need to finish to write the tests for the regex on issue-5, but as there are other solutions by passing only parameters, I'm not sure I'll add this functionality if I don't find a way to optimize and get performance.

I'll think about it.

soundstep avatar Jun 21 '13 10:06 soundstep