Posted by
Nicolas Malin (Jira) on
URL: http://ofbiz.116.s1.nabble.com/jira-Created-OFBIZ-203-Freemarker-postal-address-formatter-macro-tp171329p171338.html
[
http://issues.apache.org/jira/browse/OFBIZ-203?page=comments#action_12434275 ]
Leon Torres commented on OFBIZ-203:
-----------------------------------
In response to: "I can see that this must have required a fair amount of work, and that's exactly my concern."
Well, if you look at the capabilities of the formatter, you'll note that it only takes one format method to generate all kinds of output: text-only, html, as a list, inline, whatever. It uses simple, straightforward functions to abstract out the format details. This allows us to easily add more format modes without requiring users to re-write their formatters. For instance, if we want to add XSL:FO capability, we only need to insert this capabiility into AddressFormatter and all the custom AddressFormatter classes will automagically support it.
Replicating this ability in FTL is impractical, given that it would require tons of conditions, hard to debug situations with certain formats (text mode) and so on. For those wanting different formatting, the increase in complexity and verbosity using this approach requires a larger skill set than would be required to write or rewrite a simple Java method.
> Freemarker postal address formatter macro
> -----------------------------------------
>
> Key: OFBIZ-203
> URL:
http://issues.apache.org/jira/browse/OFBIZ-203> Project: OFBiz (The Open for Business Project)
> Issue Type: New Feature
> Components: framework
> Affects Versions: SVN trunk
> Reporter: Leon Torres
> Priority: Minor
> Attachments: ofbizPostalAddress.patch, test.bsh, test.ftl
>
>
> Define a macro <@ofbizPostalAddress address=inputMapOrGenericValue/> to format postal addresses in a consistent, flexible way with attention to country postal formats. The output should support both HTML and Text formats. It should be easily extensible, with future XSL:Fo support in mind.
> I created an implementation as an exercise to learn the freemarker template system. It was designed with future macros in mind. Currently implemented are rules for generating US, German and Royal Mail format postal addresses. (The address country determines the format.) Also provided are test.bsh and test.ftl so people may try them out.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.apache.org/jira/secure/Administrators.jspa-
For more information on JIRA, see:
http://www.atlassian.com/software/jira