You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Charles N. Harvey III" <ch...@alloy.com> on 2002/05/22 17:01:18 UTC

how does merge work?

I am trying to dig through the code to figure out how the merge
functionality
works.  I am getting there but could use a few pointers.

>From what I understand it works thusly:

- look for template
	- if not present, send rnfe error to log
	- if present, check for syntax errors
		- if template has syntax errors, send error to log
		- if template is good, parse template
			- get any #parse(d) and #include(d) templates
				- look for template
					- if not present...
					...
					...
			- extract context objects into variables in template
			- display


That's what I've got so far.  I understand the looking for and parsing
parts.  Well, the looking for mostly, I am digging around to understand
the parsing.  But I really need help with the extracting of context info
and how a page actually gets displayed (how it is read in and pumped out).

Thanks so much.

Charlie


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: how does merge work?

Posted by "Charles N. Harvey III" <ch...@alloy.com>.
It is related to my poorly posted question yesterday concerning jsp.
I cannot win over some stodgy developers with Velocity but I have
gotten them to accept no java in a jsp page.  Well, if that is the
case then why can't the jsp page be treated as a "template"?  So my
thinking is to try to have jsp pages parsed as templates.  Now, this
is way too much work and most likely way too difficult for someone
like me, but I wanted to see where it would lead.  And if I am going
to be copying an idea, might as well start with the best example around.

So yeah, I'm going to see if I can hack together a copy of how velocity
merges and use it for jsp with taglibs.  Pretty disgusting isn't it.

Thanks for the info though - quite helpful.

Charlie

> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
> Sent: Wednesday, May 22, 2002 11:09 AM
> To: velocity-user@jakarta.apache.org
> Subject: Re: how does merge work?
>
>
> On 5/22/02 11:01 AM, "Charles N. Harvey III" <ch...@alloy.com> wrote:
>
> > I am trying to dig through the code to figure out how the merge
> > functionality
> > works.  I am getting there but could use a few pointers.
> >
> > From what I understand it works thusly:
> >
> > - look for template
> > - if not present, send rnfe error to log
> > - if present, check for syntax errors
> > - if template has syntax errors, send error to log
> > - if template is good, parse template
> > - get any #parse(d) and #include(d) templates
> > - look for template
> > - if not present...
> > ...
> > ...
> > - extract context objects into variables in template
> > - display
> >
> >
> > That's what I've got so far.  I understand the looking for and parsing
> > parts.  Well, the looking for mostly, I am digging around to understand
> > the parsing.  But I really need help with the extracting of context info
> > and how a page actually gets displayed (how it is read in and
> pumped out).
>
> There are actually a few things going on when you merge, and the word
> 'merge' means a few things depending on context.
>
> The upshot :
>
> 1) find the template.  If not found, error.  If found and not
> cached, parse
> and put in cache.  Parse problem?  Error.  If in cache and not
> expired, just
> use.
>
> 2) take the context with data, do some wrapping for housekeeping, and then
> with a writer, send it down the syntax tree of the template.  If anything
> goes wrong (like a method  $foo.bar() throws an exception, and no handler)
> stop.
>
> 3) going down the tree, render each node into the writer.
>
> What exactly are you trying to figure out? (Or is there a specific problem
> you are trying to solve?)
>
> --
> Geir Magnusson Jr.
> Research & Development, Adeptra Inc.
> geirm@adeptra.com
> +1-203-247-1713
>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: how does merge work?

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 5/22/02 11:01 AM, "Charles N. Harvey III" <ch...@alloy.com> wrote:

> I am trying to dig through the code to figure out how the merge
> functionality
> works.  I am getting there but could use a few pointers.
> 
> From what I understand it works thusly:
> 
> - look for template
> - if not present, send rnfe error to log
> - if present, check for syntax errors
> - if template has syntax errors, send error to log
> - if template is good, parse template
> - get any #parse(d) and #include(d) templates
> - look for template
> - if not present...
> ...
> ...
> - extract context objects into variables in template
> - display
> 
> 
> That's what I've got so far.  I understand the looking for and parsing
> parts.  Well, the looking for mostly, I am digging around to understand
> the parsing.  But I really need help with the extracting of context info
> and how a page actually gets displayed (how it is read in and pumped out).

There are actually a few things going on when you merge, and the word
'merge' means a few things depending on context.

The upshot :

1) find the template.  If not found, error.  If found and not cached, parse
and put in cache.  Parse problem?  Error.  If in cache and not expired, just
use.

2) take the context with data, do some wrapping for housekeeping, and then
with a writer, send it down the syntax tree of the template.  If anything
goes wrong (like a method  $foo.bar() throws an exception, and no handler)
stop.

3) going down the tree, render each node into the writer.

What exactly are you trying to figure out? (Or is there a specific problem
you are trying to solve?)

-- 
Geir Magnusson Jr.
Research & Development, Adeptra Inc.
geirm@adeptra.com
+1-203-247-1713



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>