getpublic
Dynamically look up a property on an object. The second argument to {{get}} should have a string value, although it can be bound.
For example, these two usages are equivilent:
{{person.height}}
{{get person "height"}}
If there were several facts about a person, the {{get}} helper can dynamically pick one:
{{get person factName}}
For a more complex example, this template would allow the user to switch between showing the user's height and weight with a click:
{{get person factName}}
<button {{action (mut factName) "height"}}>Show height</button>
<button {{action (mut factName) "weight"}}>Show weight</button>
The {{get}} helper can also respect mutable values itself. For example:
{{input value=(mut (get person factName)) type="text"}}
<button {{action (mut factName) "height"}}>Show height</button>
<button {{action (mut factName) "weight"}}>Show weight</button>
Would allow the user to swap what fact is being displayed, and also edit that fact via a two-way mutable binding.
Please login to continue.