Re: [Freemarker-devel] [vote] Opinions about conditional built-in names?
Generates text that depends on changing data (like dynamic HTML).
Brought to you by:
revusky
From: Denis B. <bre...@ma...> - 2015-06-05 20:18:15
|
Hi, >> I think you should keep it at "then". >> >> To take your example again: >> >> loggedin?thenElse(username, "unknown") >> >> It is confusing to read. > > To me: ?thenElse is less "fluent", OTOH I guess if someone stops and > thinks a bit, he has better chance to realize what it means than with > ?then. OTOH ?then is shorter, and if you have already used to it, more > pleasant to read. Yes ?then() has my vote. >> Also, can the default value be optional ? This builtin could double as another way to write: >> >> loggedin!username >> >> This is clearer: >> >> loggedin?then(username) > > `loggedin!username` just associates a default value to `loggedin` if > `loggedin` is missing. It doesn't care if `loggedin` is `true` or > `false`, as those are both non-missing values. `?then` on the other > hand deals with existing boolean values. So they don't overlap. Oops, you’re right. Brain slip. It would be more like: username!anonymousUser I think it is clear what it does. — Denis. |