Proposal for new Macros and Filter
Macros
- now(offset) - current Date + offset
- renderSkin(skin) - renders the given skin, should be in HopObject & Global
- random(from, to) - returns a random between 0 and 1 or param.from to param.to
- queryParam(name) - returns the req.queryParam
- postParam(name) - returns the req.postParam
Filters
- append(str) - append the str to the incomming string.
- prepend(str) - like append.
- boolean(true, false) - return the true or false parameter, depending on input
- if(x, is, a, then, y, else, z) - http://code.google.com/p/antville/source/browse/trunk/code/Global/Global.js#237
- switch(case1, case2, ...) - return the value of the case defined by the input
- isNaN - returns true or false, maybe followed by a boolean-filter
- isNull - returns true or false, maybe followed by a boolean-filter
- isLowerThan(val) - returns true or false, maybe followed by a boolean-filter
- isBiggerThan(val) - returns true or false, maybe followed by a boolean-filter
- isEqual(val) - returns true or false, maybe followed by a boolean-filter
- toggle(option1, option2) - toggles between option1 or option2
- formatDuration - formats the incomming input from seconds to HH:mm:ss
- formatFilesize(to) - formats the incomming filesize in byte KB, MB, GB, TB
- formatNumber - calls Helma's Number.format()
- formatParagraphs - call Helma's formatParagraphs()
- macroTag - render the input in macro-tags, e.g. "mymacro" | macroTag should return " [Unhandled macro: mymacro] "
- bindHandler - bind the input object to res.handlers[param.name]
- dateOffset(days,months,years) - increases the incomming Date by the given params
- link - call html.linkAsString()
- href - call the href on the input object
- toFixed(c) - calls Number.toFixed(c)
Comments
I'm not sure if this is a great idea or not, but isNotNull and isNotNaN might increase the readability of skins, even if they are just inverse to isNull and isNaN.
Another interesting idea:
<% this.stories | each call renderSkinAsString skin="aSkinFromStory" param=<% param.clone %> %>