Olivier wrote:
> 
> On Thu, Oct 05, 2000 at 05:36:46PM -0400, Geir Magnusson Jr. wrote:
>
> I am doing similar things. Also what you describe works fine it does not
> seems the most logical to me.

No, it probably isn't.  But as a simple person, I have simple needs, and
that solves them.

> I guest what you have is a structure with two objects: the main page
> object and a Body object. Each of these objects (I guess) have some
> logic to decide which template should be use to serve a particular
> request, the main one decide which layout to use and the body which
> content to serve.

That's right, sort of.

> 
> However with Velocity when the 'main Page' object call template 1, there
> is no way to give back the control to the 'body' object.
> 
> To work around this what you do is to determine everything before
> hand: before the first call to template1 and all the hierarchy of nested
> templates and data.
> Which means that you add to the context all the template names and
> data which are going to be used by the nested #parse calls.

Definitely.  Everything that I put into the context() are objects that I
know will provide data when the template is being rendered.  Before I
put them in, I have done all db accesses, calculations, etc because I
want to be confident that the template will render.  If there is a
problem, I can send the user to a "We're sorry... please try again..."
type of page.  I wont't get caught halfway through the render if the
database has a problem.

I try to design/develop with the assumption/rule that the Controller
server is in charge of deciding based on user application context what
is next to be shown to the user, using the classes comprising the data
Model to get that data, and then simply invoking the View via choosing
the appropriate templates to render that information.  Whenever I have
come across the situation where I wanted to make choices in View about
rendering, I was conflicting with my assumption/rule, and reworked what
I was doing in order to be consistant.  It may not be the most elegant
approach, but the results are satisfactory so far.  I guess only the
ease of ongoing maintenance and extension will tell if this consistency
will pay off.

But this isn't due to limits in Velocity (or Webmacro, what it's built
under - I will switch to Vel Real Soon Now, especially if the
Velocimacros get put in there, and if not, I will put them into my own
personalized Vel :)  I do it this way because I want to, and WM/Vel are
great tools to do it with.

> 
> This is ok if you have one nested object but become very messy if
> you have 5 or 6 levels of depth.
> Something like:
> 
> Page
>   Body
>     Layout
>       Latest news container
>         News item 1
>           Author 1
>           Author 2
>         News item 2
>           Author 3
> 
> One way around this would be the ability to set some sort of break
> points in a template. So, the 'main page' object could call the
> 'merge' method to render a template from the start to the first break
> point, then the control would return back to the 'main page' object
> which could let the 'body' object insert futher templates or data ,
> then finally re-enter template 1 and render from the break-point to
> the end.

Yes, but I think that you could do that using the rules I personally
work under.   Further, if the sections of template code that rendered
things like the news items were small, more like 'template-ettes', that
seems to be a very appropriate use for 

        <bah-dah!>   Velocimacros

(sorry.  Needed to plug it one more time - I want Jason to get this to a
formal vote :)

Anyway, I would be happy to try, offline ( or over on the velocity-users
list, which I only just remembered existed) in defining a page like you
did above, and try to workout the solution, and then we can judge if it
is possible to do in a way acceptable to you.

> My original question was: do you have, yes or no, interest in the
> notion of a break-point system to do partial rendering from points to
> points in a template, so that an external traversing object could
> control the nesting.

Right now, I personally do not have an interest in that, but that's only
me. I am personally interested in exploring it with you, if you want, to
see where it may go, and what can be done with it.  If we find something
good, maybe we come back here and propose it?
 
> The answer is obviously No! That's fine, no worries!
> 
> I don't fully understand why some guy has to become excited and mix up
> hamburger recipies in the sauce!?

I don't either.  Under the rule that I mentioned above, I feel that that
hamburgers should be kept out of the sauce for the most part. :)

geir

> Regards.
> 
> Olivier.
> 
> ----------------------------------------------------------------------
> Olivier Louchart-Fletcher
> Email: [EMAIL PROTECTED]

-- 
Geir Magnusson Jr.                               [EMAIL PROTECTED]
Dakota tribal wisdom: "when you discover you are riding a dead horse,
the best strategy is to dismount."

Reply via email to