[Helma-user] finally: if-then-else in generic helma skins
tobias.schaefer at orf.at
tobias.schaefer at orf.at
Thu May 10 12:48:20 CEST 2007
hi there
just wanted to share this little global macro since the feature was requested so many times (and i was one of its rather passionate opponents :) and it's now possible to do it with helma 1.6:
// <% if <% macro %> is "value" then "yes" else "no" %>
// <% if <% macro1 %> is "value" then <% macro2 %> else <% macro3 %> %>
var if_macro = function(param, value1, _is_, value2, _then_, thenStatement, _else_, elseStatement) {
return (("" + value1) == ("" + value2)) ? thenStatement : elseStatement;
};
of course it lacks any syntax checking, but that's probably pretty trivial to add.
(a minor drawback, though i am not sure about it: i think in the second example all three macros will be evaluated -- which would be a waste of resources. thus, the macro probably is only applicaple in a development scenario for quick testing etc.)
ciao,
tobi
More information about the Helma-user
mailing list