[Templates] Template::Plugin::XML::Writer

Addison, Mark Mark.Addison@itn.co.uk
Thu, 13 Jul 2006 14:09:21 +0100


This is a multi-part message in MIME format.

------=_NextPart_000_1B2B_01C6A686.440C8EE0
Content-Transfer-Encoding: 7bit
Content-Type: multipart/alternative;
	boundary="----_=_NextPart_001_01C6A67D.E21FBFAF"


------_=_NextPart_001_01C6A67D.E21FBFAF
Content-Type: text/plain; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

From: Perrin Harkins Sent: Tue 7/11/2006 6:36 PM
> On Tue, 2006-07-11 at 18:25 +0100, Addison, Mark wrote:
> > We have an export system and presentation layer built
> > around TT for output generation (multiple formats, not
> > just XML). I didn't want to enable PERL blocks in the
> > templates or change the exporter code adding an extra
> > path to pass a script instead of a template for output
> > generation (which would still expose Perl going in).
>
> I don't mean to pick on you,

I'm game ;-)

> but I do see several problems with this approach:
> - It's not a template.

I what sense? The example was pretty contrived but how I
actually use it is to pass in a bunch of vars to substitute
into the XML. Seems like a template to me.
What about something like:

 [% xw =3D XML.Writer %]
 <html>
   <head>
     <title>[% doc.title | html %]</title>
     [% FOREACH name IN doc.meta.keys ;
          xw.emptyTag('meta', name=3D>name, content=3D>doc.meta.$name);
        END; %]
   </head>
   <body>

> - It doesn't get the syntax checking that perl code normally would.

Of course, it gets the syntax checking that templates normally do.
The main issue I see here is calling non-existant methods doesn't
error, but you get this with passed in objects in vars as much as
plugins. (I'd like a safe option that caused a template error
if you called a missing method.)

> - It can't be debugged or profiled in the normal ways.

In the normal ways you do with templates.
Whats stopping you profilling TT code?
(I'm pobably luck in never really having performace problems
with templates.)

> - It's a low slower than it needs to be.

Depends how fast it needs to be. Hard to say without
some profilling. Templates complile down to a perl script
so it's not much different, apart from some extra calls
due to the plugin wrapping. My main objective was to get
XML::Writer functionality, not performance.
It seems to perform as well as more traditional XML
generating templates for my needs.

> But then I'm against the DBI plugin too, so it's safe to say I'm in the
> minority.

:) I'm probably with you on that one, the DBI plugin
definatley makes me uneasy.

You snipped the bit about non-perl coders. Do you not think
XML::Writer could be useful functionality to expose to
Template coders?

cheers,
mark
--
=20





MARK ADDISON
WEB DEVELOPER

200 GRAY'S INN ROAD
LONDON
WC1X 8XZ
UNITED KINGDOM
T +44 (0)20 7430 4678
F=20
E MARK.ADDISON@ITN.CO.UK
WWW.ITN.CO.UK
Please Note:

=20

Any views or opinions are solely those of the author and do not necessarily=
 represent=20
those of Independent Television News Limited unless specifically stated.=20
This email and any files attached are confidential and intended solely for =
the use of the individual
or entity to which they are addressed.=20
If you have received this email in error, please notify postmaster@itn.co.u=
k=20

Please note that to ensure regulatory compliance and for the protection of =
our clients and business,
we may monitor and read messages sent to and from our systems.

Thank You.


------_=_NextPart_001_01C6A67D.E21FBFAF
Content-Type: text/html; charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<HTML >
<HEAD>
<META http-equiv=3D"Content-Type" content=3D"text/html; charset=3Diso-8859-=
1">



<META NAME=3D"Generator" CONTENT=3D"MS Exchange Server version 6.5.7638.1">
<TITLE>RE: [Templates] Template::Plugin::XML::Writer</TITLE>
</HEAD>
<BODY VLINK=3D"#000000" ALINK=3D"#000000" LINK=3D"#000000" >
<DIV>
<FONT FACE=3D"Arial" SIZE=3D"2">
<!-- Converted from text/plain format -->

<P><FONT SIZE=3D2>From: Perrin Harkins Sent: Tue 7/11/2006 6:36 PM<BR>
&gt; On Tue, 2006-07-11 at 18:25 +0100, Addison, Mark wrote:<BR>
&gt; &gt; We have an export system and presentation layer built<BR>
&gt; &gt; around TT for output generation (multiple formats, not<BR>
&gt; &gt; just XML). I didn't want to enable PERL blocks in the<BR>
&gt; &gt; templates or change the exporter code adding an extra<BR>
&gt; &gt; path to pass a script instead of a template for output<BR>
&gt; &gt; generation (which would still expose Perl going in).<BR>
&gt;<BR>
&gt; I don't mean to pick on you,<BR>
<BR>
I'm game ;-)<BR>
<BR>
&gt; but I do see several problems with this approach:<BR>
&gt; - It's not a template.<BR>
<BR>
I what sense? The example was pretty contrived but how I<BR>
actually use it is to pass in a bunch of vars to substitute<BR>
into the XML. Seems like a template to me.<BR>
What about something like:<BR>
<BR>
&nbsp;[% xw =3D XML.Writer %]<BR>
&nbsp;&lt;html&gt;<BR>
&nbsp;&nbsp; &lt;head&gt;<BR>
&nbsp;&nbsp;&nbsp;&nbsp; &lt;title&gt;[% doc.title | html %]&lt;/title&gt;<=
BR>
&nbsp;&nbsp;&nbsp;&nbsp; [% FOREACH name IN doc.meta.keys ;<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; xw.emptyTag('meta', =
name=3D&gt;name, content=3D&gt;doc.meta.$name);<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; END; %]<BR>
&nbsp;&nbsp; &lt;/head&gt;<BR>
&nbsp;&nbsp; &lt;body&gt;<BR>
<BR>
&gt; - It doesn't get the syntax checking that perl code normally would.<BR>
<BR>
Of course, it gets the syntax checking that templates normally do.<BR>
The main issue I see here is calling non-existant methods doesn't<BR>
error, but you get this with passed in objects in vars as much as<BR>
plugins. (I'd like a safe option that caused a template error<BR>
if you called a missing method.)<BR>
<BR>
&gt; - It can't be debugged or profiled in the normal ways.<BR>
<BR>
In the normal ways you do with templates.<BR>
Whats stopping you profilling TT code?<BR>
(I'm pobably luck in never really having performace problems<BR>
with templates.)<BR>
<BR>
&gt; - It's a low slower than it needs to be.<BR>
<BR>
Depends how fast it needs to be. Hard to say without<BR>
some profilling. Templates complile down to a perl script<BR>
so it's not much different, apart from some extra calls<BR>
due to the plugin wrapping. My main objective was to get<BR>
XML::Writer functionality, not performance.<BR>
It seems to perform as well as more traditional XML<BR>
generating templates for my needs.<BR>
<BR>
&gt; But then I'm against the DBI plugin too, so it's safe to say I'm in th=
e<BR>
&gt; minority.<BR>
<BR>
:) I'm probably with you on that one, the DBI plugin<BR>
definatley makes me uneasy.<BR>
<BR>
You snipped the bit about non-perl coders. Do you not think<BR>
XML::Writer could be useful functionality to expose to<BR>
Template coders?<BR>
<BR>
cheers,<BR>
mark<BR>
--<BR>
<BR>
<BR>
</FONT>
</P>

</FONT>
</DIV>
<DIV>&nbsp;</DIV>
<DIV>
<FONT FACE=3D"Arial">
</FONT>
</DIV>
<FONT SIZE=3D"2">
</FONT>
<DIV>
<FONT FACE=3D"Arial">
</FONT>
</DIV>
<DIV>
<FONT FACE=3D"Arial" COLOR=3D"#cccc00" SIZE=3D"1"><STRONG></STRONG></FONT>
</DIV>
<DIV>
<FONT FACE=3D"Arial" COLOR=3D"#cccc00" SIZE=3D"1"><STRONG></STRONG></FONT>
</DIV>
<DIV>
<FONT FACE=3D"Arial" COLOR=3D"#cccc00" SIZE=3D"1"><STRONG><IMG ALT=3D"" HSP=
ACE=3D"0" SRC=3D"cid:1739c0fe99@2f374e04-4d1b" ALIGN=3D"baseline" BORDER=3D=
"0"></STRONG></FONT>
</DIV>
<DIV>
<FONT FACE=3D"Arial" COLOR=3D"#cccc00" SIZE=3D"1"><STRONG>MARK ADDISON<BR><=
/STRONG></FONT>
<FONT FACE=3D"Arial" COLOR=3D"#cccc00" SIZE=3D"1"><STRONG>WEB DEVELOPER<BR>=
</STRONG></FONT><!--<DIV><FONT FACE=3D"Arial" SIZE=3D"1"></FONT>&#160;<DIV>=
</DIV>-->
<FONT FACE=3D"Arial" SIZE=3D"1"><BR>200 GRAY'S INN ROAD<BR></FONT>
<FONT FACE=3D"Arial" SIZE=3D"1">LONDON<BR></FONT>
<FONT FACE=3D"Arial" SIZE=3D"1">WC1X 8XZ<BR></FONT>
<FONT FACE=3D"Arial" SIZE=3D"1">UNITED KINGDOM<BR>T +44 (0)20 7430 4678<BR>=
</FONT>
<FONT FACE=3D"Arial" SIZE=3D"1">F <BR></FONT>
<FONT FACE=3D"Arial" SIZE=3D"1">E MARK.ADDISON@ITN.CO.UK<BR></FONT>
<FONT SIZE=3D"1">
<FONT FACE=3D"Arial">
<FONT COLOR=3D"black"><A HREF=3D"http://WWW.ITN.CO.UK">WWW.ITN.CO.UK</A><A>=
</A><A></A><A></A><A></A><A></A><A></A><A></A><A></A><BR></FONT>
</FONT>
</FONT>
</DIV>
<FONT SIZE=3D"+0">
</FONT>
<FONT SIZE=3D"+0">
</FONT>
<FONT SIZE=3D"+0">
</FONT>
<FONT SIZE=3D"+0">
</FONT>
<FONT SIZE=3D"+0">
</FONT>
<FONT SIZE=3D"+0">
</FONT>
<FONT SIZE=3D"1">
<FONT COLOR=3D"black"><A></A><A></A><A></A><A></A><A></A><A></A><A></A><A><=
/A><A></A><A></A><A></A></FONT><A></A><A></A><A></A><A></A><A></A><A></A><A=
></A><A></A><A></A><A></A><A></A><A></A><FONT FACE=3D"Arial"><BR></FONT><A>=
</A></FONT><pre>Please Note:

=20

Any views or opinions are solely those of the author and do not necessarily=
 represent=20
those of Independent Television News Limited unless specifically stated.=20
This email and any files attached are confidential and intended solely for =
the use of the individual
or entity to which they are addressed.=20
If you have received this email in error, please notify postmaster@itn.co.u=
k=20

Please note that to ensure regulatory compliance and for the protection of =
our clients and business,
we may monitor and read messages sent to and from our systems.

Thank You.

</pre></BODY></HTML>

------_=_NextPart_001_01C6A67D.E21FBFAF--

------=_NextPart_000_1B2B_01C6A686.440C8EE0
Content-Type: image/gif;
	name="ITN_Master_green.gif"
Content-Transfer-Encoding: base64
Content-ID: <1739c0fe99@2f374e04-4d1b>
Content-Disposition: inline;
	filename="ITN_Master_green.gif"

R0lGODlhUAA4APcAAP///7u9AMDBEr/BEdrbddHSUfHyzP7++r2/CN3ef+/vw/X228bIKuXmntrb
c/f34dnacL7AC/HxydbXZc3OQsnLNtbXZOHij8fILObnodLTVry+BMTGIry+AsjKMcnLNezstuPk
l/7+++joqMHDF/v7787PR8zNP8TFIL2/Bu3uvObmoLy+BczNPvr67Pr67ejpqv///sfJLvT01err
sr7ADsDCE/X12srMOcbIKdXXY+Xmn/DxyMzOQfj45PHyyt/giPj448/QS/Lzz9HTVMnKNN7fhOTl
mt3efufnpOPklvHxysDCFvn56eL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