You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ofbiz.apache.org by Adrian Crum <ad...@sandglass-software.com> on 2011/06/03 07:12:01 UTC

Freemarker Macro Library

I'm working on a project where screen widgets can't be used and I need 
to use Freemarker templates instead. I would like to use the Freemarker 
macros found in the widget macro library, but they are cumbersome to use 
because they have MANY parameters - and almost all of them are set up as 
required parameters. The markup the macros generate requires only a 
handful of the parameters, and the rest of them are optional. So, I 
would like to work on the macro library and provide default arguments 
for any parameters that aren't required by the markup. Any thoughts or 
objections?

-Adrian


Re: Freemarker Macro Library

Posted by Adrian Crum <ad...@sandglass-software.com>.
That's an interesting approach, but it duplicates code. It would be 
preferable to fix the macros.

-Adrian

On 6/3/2011 10:26 AM, Bilgin Ibryam wrote:
> Hi Adrian,
>
>
> On Fri, Jun 3, 2011 at 6:12 AM, Adrian Crum<
> adrian.crum@sandglass-software.com>  wrote:
>
>> I'm working on a project where screen widgets can't be used and I need to
>> use Freemarker templates instead. I would like to use the Freemarker macros
>> found in the widget macro library, but they are cumbersome to use because
>> they have MANY parameters - and almost all of them are set up as required
>> parameters. The markup the macros generate requires only a handful of the
>> parameters, and the rest of them are optional. So, I would like to work on
>> the macro library and provide default arguments for any parameters that
>> aren't required by the markup. Any thoughts or objections?
>>
> I reused form widget lookup macros in freemarker templates using similar
> approach. Just create a wrapper macro with default values and then call the
> widget macros. For an example check how htmlTemplate.lookupField macro is
> used and implemented in htmlTemplate.ftl
>
>
> HTH
> Bilgin Ibryam
>

Re: Freemarker Macro Library

Posted by Bilgin Ibryam <bi...@gmail.com>.
Hi Adrian,


On Fri, Jun 3, 2011 at 6:12 AM, Adrian Crum <
adrian.crum@sandglass-software.com> wrote:

> I'm working on a project where screen widgets can't be used and I need to
> use Freemarker templates instead. I would like to use the Freemarker macros
> found in the widget macro library, but they are cumbersome to use because
> they have MANY parameters - and almost all of them are set up as required
> parameters. The markup the macros generate requires only a handful of the
> parameters, and the rest of them are optional. So, I would like to work on
> the macro library and provide default arguments for any parameters that
> aren't required by the markup. Any thoughts or objections?
>

I reused form widget lookup macros in freemarker templates using similar
approach. Just create a wrapper macro with default values and then call the
widget macros. For an example check how htmlTemplate.lookupField macro is
used and implemented in htmlTemplate.ftl


HTH
Bilgin Ibryam