Hi All,
I always find freemarker templates to be a real pain to try and inspect because the ftl and html code is indented together even though they represent different markup. What does everyone think about formatting the files so that ftl code is indented independently from the output? For example this is how it looks at the moment: <form> <table> <tr> <td>${uiLabelMap.WebtoolsFieldName}</td> </tr> <#assign alt_row = false> <#list fieldList as field> <tr<#if alt_row> class="alternate-row"</#if>> <td>${field.name}</td> </tr> <#assign alt_row = !alt_row> </#list> <tr> <td><input type="submit" value="${uiLabelMap.CommonFind}"></td> </tr> </table> </form> I'm suggesting we change it to this: <form> <table> <tr> <td>${uiLabelMap.WebtoolsFieldName}</td> </tr> <#assign alt_row = false> <#list fieldList as field> <tr<#if alt_row> class="alternate-row"</#if>> <td>${field.name}</td> </tr> <#assign alt_row = !alt_row> </#list> <tr> <td><input type="submit" value="${uiLabelMap.CommonFind}"></td> </tr> </table> </form> I guess on a small sample the change doesn't look like much but on large files I think it would make life a lot easier. The html output will be correctly indented and the templates will be easier to read because the ftl and html will usually sit at different indent levels so you can focus on one or the other. Thoughts? Thanks Scott HotWax Media http://www.hotwaxmedia.com smime.p7s (3K) Download Attachment |
+1 Scott.
I have suffered a lot with this pain in some of my customized projects. For highly confusing code for the same can also be seen in sidedeepcategory.ftl . I also prefer to indent html tags separately and ftl tags separately. Regards -- Chirag Manocha Scott Gray wrote: > Hi All, > > I always find freemarker templates to be a real pain to try and > inspect because the ftl and html code is indented together even though > they represent different markup. What does everyone think about > formatting the files so that ftl code is indented independently from > the output? > For example this is how it looks at the moment: > <form> > <table> > <tr> > <td>${uiLabelMap.WebtoolsFieldName}</td> > </tr> > <#assign alt_row = false> > <#list fieldList as field> > <tr<#if alt_row> class="alternate-row"</#if>> > <td>${field.name}</td> > </tr> > <#assign alt_row = !alt_row> > </#list> > <tr> > <td><input type="submit" value="${uiLabelMap.CommonFind}"></td> > </tr> > </table> > </form> > > I'm suggesting we change it to this: > <form> > <table> > <tr> > <td>${uiLabelMap.WebtoolsFieldName}</td> > </tr> > <#assign alt_row = false> > <#list fieldList as field> > <tr<#if alt_row> class="alternate-row"</#if>> > <td>${field.name}</td> > </tr> > <#assign alt_row = !alt_row> > </#list> > <tr> > <td><input type="submit" value="${uiLabelMap.CommonFind}"></td> > </tr> > </table> > </form> > > I guess on a small sample the change doesn't look like much but on > large files I think it would make life a lot easier. The html output > will be correctly indented and the templates will be easier to read > because the ftl and html will usually sit at different indent levels > so you can focus on one or the other. > > Thoughts? > > Thanks > Scott > > HotWax Media > http://www.hotwaxmedia.com |
In reply to this post by Scott Gray-2
Hi scott,
it's a good idea, I use this method this few month. The problem, on large file, it's difficult to use double formating and I don't found a good assistant to do an auto-format. If I have been many time I rewrite the actual ftl helper for eclipse but It's not the case. Nicolas Scott Gray wrote: > Hi All, > > I always find freemarker templates to be a real pain to try and > inspect because the ftl and html code is indented together even though > they represent different markup. What does everyone think about > formatting the files so that ftl code is indented independently from > the output? > For example this is how it looks at the moment: > <form> > <table> > <tr> > <td>${uiLabelMap.WebtoolsFieldName}</td> > </tr> > <#assign alt_row = false> > <#list fieldList as field> > <tr<#if alt_row> class="alternate-row"</#if>> > <td>${field.name}</td> > </tr> > <#assign alt_row = !alt_row> > </#list> > <tr> > <td><input type="submit" value="${uiLabelMap.CommonFind}"></td> > </tr> > </table> > </form> > > I'm suggesting we change it to this: > <form> > <table> > <tr> > <td>${uiLabelMap.WebtoolsFieldName}</td> > </tr> > <#assign alt_row = false> > <#list fieldList as field> > <tr<#if alt_row> class="alternate-row"</#if>> > <td>${field.name}</td> > </tr> > <#assign alt_row = !alt_row> > </#list> > <tr> > <td><input type="submit" value="${uiLabelMap.CommonFind}"></td> > </tr> > </table> > </form> > > I guess on a small sample the change doesn't look like much but on > large files I think it would make life a lot easier. The html output > will be correctly indented and the templates will be easier to read > because the ftl and html will usually sit at different indent levels > so you can focus on one or the other. > > Thoughts? > > Thanks > Scott > > HotWax Media > http://www.hotwaxmedia.com |
Free forum by Nabble | Edit this page |