I want to use a function to pull the last item of an array (usually of time). Right now I am doing
<script>
function current(item) {
if (!item || item.constructor != Array) {
return item;
} else {
return (item.length == 0) ? null : item[item.length - 1];
}
}
</script>
<p data-f-bind="Time,Inventory"> The current time is <%= current(Time) %> and inventory is <%= current(Inventory) %>
<p>
I thought I could make this into a converter but it didn't work
<script>
Flow.dom.attributes.register('current', function (item) {
if (!item || item.constructor != Array) {
return item;
} else {
return (item.length == 0) ? null : item[item.length - 1];
}
});
</script>
<p data-f-bind="Time,Inventory | current">
The current time is <%= Time %> and inventory is <%= Inventory %>
</p>
I get an error "converter-manager.js:159. Uncaught Error: Could not find converter for current"
Can we support converters with the example above? I think it'd be ok to have the converter applied to all variables in the list.
I want to use a function to pull the last item of an array (usually of time). Right now I am doing
I thought I could make this into a converter but it didn't work
I get an error "converter-manager.js:159. Uncaught Error: Could not find converter for current"
Can we support converters with the example above? I think it'd be ok to have the converter applied to all variables in the list.