jostsg/Iron.js — Issue #3: add support for modifier functions
Author: NicBright
Created: 2011-11-28 16:10:08+00:00
State: open

The following feature request is best described by an example:

Consider this use-case, in which you want to display a shortened file name in the innerHTML but want to store the full file name inside the title-attribute:
*

If you were able to add a modifier function you wouldn't need to create the nameShortened property before you register your data with your view:

var file = {"name": "myReallyLongFileName.jpg"};
file.nameShortened = shortenFileName(file.name);

Instead you could have iron.js do that for you:

*

So the innerHTML would be set to shortenFileName(file.name);

An alternative syntax could be:
*

I don't know if you can call globally defined functions this way (if you have their name as a string), so a suitable way to work around this might be to define / add the functions to the View:

var myView = new Class({
Extends: Iron.View,
id: 'myView',
shortenFileName: function() { ... }
});