[ZPT] METAL expansion only when editing
John Morton
jwm@plain.co.nz
Tue, 11 Sep 2001 01:47:51 +1200
On Monday 10 September 2001 19:23, Peter Bengtsson wrote:
> Ok then.
>
> What is the difference between using macros or tal:replace when you're
> always having the little "Expand while editing" thing off?
If you're using tal:replace to drop a fragment of markup into another=20
document, it can't be a full html document in it's own right. This means =
that=20
it won't behave itself when edited in an html editor and can't be feed to=
=20
tools like 'tidy' to verify that it's fully formed html or xhtml and so o=
n.=20
If you use metal instead, you can include all the usual document scaffold=
ing=20
to keep those tools happy, and mark out the bit that you want to use as a=
=20
macro.=20
One of the nice things about METAL is that it makes it fairly easy to bui=
ld a=20
tool to discover the relationships between a set of page tempates - what =
is=20
use where, what fills slots in some template and so on - as you can be pr=
etty=20
sure that anything refered to in a METAL statement is going to be some pa=
ge=20
template. If you use tal:replace, you can't be sure that the thing refere=
d to=20
by the statement isn't an attribute of some object, or what the object is=
=20
without practically rendering each and every template.=20
> What is most precious to me is processing speed in this case. We must
> avoid all luxiurios editing options to gain time.
Macro expansion is cheap as far as I know; no more expensive than tal:rep=
lace=20
and conveniently separate from all other tal command. Certainly, Zope=20
routinely does other more expensive operations every access (aquisition,=20
security checks and so on).
John