Freemarker Macro Library

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Freemarker Macro Library

Adrian Crum-3
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

Reply | Threaded
Open this post in threaded view
|

Re: Freemarker Macro Library

Bilgin Ibryam-2
Hi Adrian,


On Fri, Jun 3, 2011 at 6:12 AM, Adrian Crum <
[hidden email]> 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
Reply | Threaded
Open this post in threaded view
|

Re: Freemarker Macro Library

Adrian Crum-3
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<
> [hidden email]>  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
>