Question about formatting ftl macros with embedded html code

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

Question about formatting ftl macros with embedded html code

Jacopo Cappellato-4
What is the best way to format the code of a Fremarker macro  
containing embedded html code, used to implement the widget renderers?

Let's consider, for example:

<#macro renderFieldTitle style title><#if style?has_content><span  
class="${style}"></#if>${title}<#if style?has_content></span></#if></
#macro>

Should we try to format it to maximize its readibility? For example:

<#macro renderFieldTitle style title>
     <#if style?has_content>
         <span class="${style}">
     </#if>
     ${title}
     <#if style?has_content>
         </span>
     </#if>
</#macro>

Or should we format it so that the generated code (html) is more  
readable? For example:

<#macro renderFieldTitle style title><#if style?has_content><span  
class="${style}"></#if>
   ${title}
<#if style?has_content></span></#if></#macro>

I am trying to improve the new widget macro libraries and I am not  
sure how to proceed.

Jacopo


smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Question about formatting ftl macros with embedded html code

Scott Gray-2
Hi Jacopo

Have you had a look at any of the stuff here: http://freemarker.sourceforge.net/docs/dgui_misc_whitespace.html ?

It might be possible to find the best of both worlds.

Regards
Scott


On 18/04/2009, at 2:04 AM, Jacopo Cappellato wrote:

What is the best way to format the code of a Fremarker macro containing embedded html code, used to implement the widget renderers?

Let's consider, for example:

<#macro renderFieldTitle style title><#if style?has_content><span class="${style}"></#if>${title}<#if style?has_content></span></#if></#macro>

Should we try to format it to maximize its readibility? For example:

<#macro renderFieldTitle style title>
   <#if style?has_content>
       <span class="${style}">
   </#if>
   ${title}
   <#if style?has_content>
       </span>
   </#if>
</#macro>

Or should we format it so that the generated code (html) is more readable? For example:

<#macro renderFieldTitle style title><#if style?has_content><span class="${style}"></#if>
 ${title}
<#if style?has_content></span></#if></#macro>

I am trying to improve the new widget macro libraries and I am not sure how to proceed.

Jacopo



smime.p7s (3K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Question about formatting ftl macros with embedded html code

Jacopo Cappellato-4
Thanks Scott,

this is exactly what I was looking for.

Jacopo

On Apr 17, 2009, at 4:19 PM, Scott Gray wrote:

> Hi Jacopo
>
> Have you had a look at any of the stuff here: http://freemarker.sourceforge.net/docs/dgui_misc_whitespace.html 
>  ?
>
> It might be possible to find the best of both worlds.
>
> Regards
> Scott
>
> HotWax Media
> http://www.hotwaxmedia.com
>
> On 18/04/2009, at 2:04 AM, Jacopo Cappellato wrote:
>
>> What is the best way to format the code of a Fremarker macro  
>> containing embedded html code, used to implement the widget  
>> renderers?
>>
>> Let's consider, for example:
>>
>> <#macro renderFieldTitle style title><#if style?has_content><span  
>> class="${style}"></#if>${title}<#if style?has_content></span></
>> #if></#macro>
>>
>> Should we try to format it to maximize its readibility? For example:
>>
>> <#macro renderFieldTitle style title>
>>    <#if style?has_content>
>>        <span class="${style}">
>>    </#if>
>>    ${title}
>>    <#if style?has_content>
>>        </span>
>>    </#if>
>> </#macro>
>>
>> Or should we format it so that the generated code (html) is more  
>> readable? For example:
>>
>> <#macro renderFieldTitle style title><#if style?has_content><span  
>> class="${style}"></#if>
>>  ${title}
>> <#if style?has_content></span></#if></#macro>
>>
>> I am trying to improve the new widget macro libraries and I am not  
>> sure how to proceed.
>>
>> Jacopo
>>
>


smime.p7s (3K) Download Attachment