Re: Formatting a date

Marc Palmer <[email protected]> Mon, 27 Mar 2006 11:00:23 +0100
Newsgroups gmane.comp.java.webmacro.user
Message-ID <[email protected]>
On 27 Mar 2006, at 02:47, Sven Schliesing wrote:

> That's exactly what I looked for.
>

There's another, potentially cleaner way...

----------------- "mymacros.wmm":

#macro formatDate($d)
    $Text.formatDate($d, "dd.MM.yyyy, HH:mm")
#end

----------------- "yourtemplate.wmt":

#include as macro "mymacros.wmm"

#formatDate($createdAt)


That's the way I would do it, as the usage is cleaner. However using  
directives/macros has the disadvantage of whitespace confusion/ 
issues. i.e. <img alt="#formatDate($createdAt)"/> is problematic, you  
have to do <img alt=" #formatDate($createdAt)"/> ... intuitive eh :( !

Personally, I wish that #macro or a similar macro function did not  
define what looks like a "directive". "#directive" would have been  
the right name for #macrom with hindsight (although caveats about not  
really being a directive!)... and in a strict sense I think it would  
have been nicer (with hindsight) to make it so that you have to use a  
directive to eval them. Injecting directive look-alikes into the  
templates like this is potentially confusing.

cheers



-------------------------------------------------------
This SF.Net email is sponsored by xPML, a groundbreaking scripting language
that extends applications into web and mobile media. Attend the live webcast
and join the prime developer group breaking into this new coding territory!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642