Nested components in macros (WAS: Re: [Freemarker-devel] interested in feedback with new template engine)
Denis <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
>>>> Also, I am not terribly good at writing friendly documentation and >>>> would appreciate anyone that would like to participate in the >>>> growth >>>> of this project with me especially in the docs area... >>>> >>>> Some of the features that I have address are: >>>> >>>> - can define macro parameters as nested components (which gives you >>>> the ability to create complex UI components) >>> >>> I'm not sure I understand what does this mean. For FM 2.4, we do >>> have >>> curried macros though, if that's what you had in mind. >> >> Well it was discussed a lot earlier, although certainly only me and >> Joe was responsive in that thread. I count this thing among those >> that >> the two main FM guys (or of three) don't get for unexplained reasons, >> like #nested earlier. > > I guess I never felt that there was a clear proposal that I could just > sit down and implement. (Though maybe there was and I wasn't paying > attention.) That is what I suggested-- I propose to add the following to macro: <#tagged> (call it fragment if you like) That tells FreeMarker to insert a tagged content. You would use it like that: * <#macro main> * * <table> * * <tr> * * <td colspan="2"><#tagged></td> * * </tr> * * <tr> * * <td><#tagged></td> * * <td><#tagged></td> * * </tr> * * </table> * * </#macro> * * <@main ; content1, content2, content3> * * <@content1>This content 1</@content1> * * <@content2>This content 2</@content2> * * <@content3>This content 3</@content3> * * </@main> * FreeMarker needs to ensure that all <#tagged> occurrences have a matching block in the invocation of the macro and the blocks come in the correct order. > >> Anyway, here you will find an example: >> >> http://code.google.com/p/zipscript/wiki/FreemarkerComparison >> > > The syntax implemented seems rather odd. What distinguishes the inner > parameter or component from simply another macro invocation? > > At some point earlier, I had an implementation of something similar, > but with a new directive called #fragment and then you put a fragment > in your macro invocation and you optionally could invoke #nested with > a fragment="fragmentname" specifier and it would do the nested body of > the fragment instead. > > I later pulled it out because I was redoing so many things that I > figured I'd put this back in later (or not) after the cleanup. > > I am seeing some amount of need for this because I am working on a new > project called KawaDD, a fork of JavaCC (I had to fork because the > people there were impossible) and I want to encapsulate eventually > some language constructs and then you start realizing that something > like try-catch-finally is actually a try block plus one or more catch > blocks plus a finally block, so multiple inner blocks to the macro > seems necessary to capture it cleanly. > > Now that you've had even more time to think about it, how would you > like to see it work? ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08