Olivier [SMTP:[EMAIL PROTECTED]] wrote :

> I haven't looked at #parse but I suspect that the control flows from
> templates to templates while it should really flows from nodes to
> nodes in the original tree. Again any object structure with dynamic
> branching cannot take advantage of Velocity as of now.

If I am understanding the problem correctly, I believe that #parse will
solve it.    #parse is different from #include because, well, it parses and
processes references, directives, etc, (strangely enough...).   So
references get evaluated. (Does Velocity's #parse() work yet?  dunno.
either way...)  So you can put the name of a template, say "template2.vm",
in a reference $othertemplate

So in a servlet, you could return template1.wm out of handle() :

template1.wm

    <html>
    <body>
    Blargh blargh blargh :

    #parse $othertemplate

and template2.wm

    data = $data (whatever...)

   Blargh blargh blargh.
   </body>
   </html>


so in the tree :

template1.wm
     |
     |  - template2.wm


I don't like this because you hope and pray that template2 closes things up
right with </body></html>.  I hope that you don't indend to open a <table>
in 1 and close it in 2.  Yeek.

As another example,  I have a similar need in a site I am building  I use
parse to have a 'skin' frame in an app that does site hosting -> the
controller servlet chooses the appropriate skin that was selected by the
site owner/administrator, and then chooses the appropriate 'mainbody'
template, which is a borderless, navless, footerless view on whatever data
is to be shown and puts that into the context [ context.put("mainbody",
strMainbodyTemplate ) ] and then stuffs any needed data for that mainbody
template into the context    The mainbody frames wouldn't generate a
complete page by themselves.  They have to 'live' in a frame, but they don't
care where.  That's up to the frame designer.  The frame :

<html>
<body>

Welcome to Blarght Blargh (header stuff)

<table>
    <tr>
        <td>
              leftside navigational junk, usually dynamic from db
        </td>
          <td>
                    #parse $mainbody
            </td>
    <td>
            rightside commerce store callouts, from db
    </td>
</tr>
</table>
footer stuff
</body>
</html>


I don't know if this is the 'right' way to do it, but it works.

Is this what you were thinking?

geir


Reply via email to