Closed MeirionHughes closed 8 years ago
I'm submitting a feature request
Add Math (global static) to the context for all string interpolations
Math
should facilitate the use of any Math function in any interpolation: i.e.
<div>${Math.sin(Math.PI/2)}<div> would output <div>1</div>
<div>
<div>1</div>
becomes far more useful in svg though.
<line class="slice" repeat.for="i of slices" x1="${cx}" x2="${cx + r * Math.sin(i * ((Math.PI * 2) / slices)) }" y1="${cy}" y2="${cy + r * -Math.cos(i * ((Math.PI * 2) / slices)) }"/>
Current behavior: Math isn't found and the interpolation fails.
Expected/desired behavior:
Math can be used by interpolation and the interpolation produces the correct output.
What is the motivation / use case for changing the behavior?
Especially useful for SVG elements that require use of sin/cos for placement; without polluting view-model with presentation variables.
Workaround
Manually add Math to view-model:
Math:Math; constructor() { this.Math = Math; }
We aren't going to support globals in the binding language. Suggest you use the workaround or create a binding engine hook to add Math to the view's override context.
I'm submitting a feature request
Add
Math
(global static) to the context for all string interpolationsshould facilitate the use of any
Math
function in any interpolation: i.e.<div>
${Math.sin(Math.PI/2)}<div>
would output<div>1</div>
becomes far more useful in svg though.
Current behavior:
Math
isn't found and the interpolation fails.Expected/desired behavior:
Math
can be used by interpolation and the interpolation produces the correct output.What is the motivation / use case for changing the behavior?
Especially useful for SVG elements that require use of sin/cos for placement; without polluting view-model with presentation variables.
Workaround
Manually add Math to view-model: