Re: got tired of waiting for IDE support - new tool to preview FreeMarker templates
Denis <[email protected]>
| Newsgroups | gmane.comp.web.freemarker.user |
|---|---|
| Message-ID | <[email protected]> |
On 9 avr. 08, at 23:42, Jonathan Revusky <[email protected]> wrote: > On Wed, Apr 9, 2008 at 1:49 PM, Jeromy Evans > <[email protected]> wrote: >> Daniel Dekany wrote: >>> >>> I think many will find it useful, also it would be useful for >>> learning >>> FTL. However, the context model should support numbers, boolean, >>> dates, and maps and lists as variables. So it should be recursive >>> (due >>> to nested maps and lists), and there should be pulldown to chose the >>> variable type (that defaults to string). >>> >>> > > Actually, in my thinking about this kind of tool, I often end up > thinking that there is a general need in FreeMarker for more literal > types. Of course, the normal usage of a templating engine is that the > data comes from outside the template (that's even really the whole > point) and then there's all that ultra purist separation of concerns > stuff.... BUT OTOH, in various contexts, it looks to me to be quite > useful to be able to define fairly complex sample data on the page > itself. Just from the point of view of unit testing, the idea that the > template is its own unit test, except that it needs some sample data. > > I was wondering whether having a literal type for something like JSON > or YAML (I think YAML is really a superset of JSON), so that you could > maybe just define a whole data model right in FTL. > > <#assign dataModel = y" > arbitrarily nested blah blah > "> > > (That's assuming a syntax roughly like that of raw strings.) > > Another syntax that occurred to me was x{....} with the idea being > that this is an extended version of {...} the literal map syntax. > Though maybe x would be better to keep for an XML literal type. > > Also, I was wondering about having it as an option in the FTL tag, > like: > > <#ftl testdata=x{ > ... > }> > > I mean, there's the general problem wrt tools, that in order to > display the template, you do need some sample data set to work with. >> From a learning POV, the ability to define some data in the page and > then just output it looks pretty attractive. Well, not just for > learning, a tool that helps you edit templates could have a preview > facility, but there is a need for some sample data for that. >> >>> >>> >> >>> >> >> >> >> >> Would it be that hard to write a Java-side macro that parses its text and adds variables in the datamodel? ------------------------------------------------------------------------- This SF.net email is sponsored by the 2008 JavaOne(SM) Conference Don't miss this year's exciting event. There's still time to save $100. Use priority code J8TL2D2. http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone