soma-template
soma-template copied to clipboard
Parse functions in parameters
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>
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.