in reply to Re: Template Toolkit and XML
in thread Template Toolkit and XML

I've thought about parsing first, and then placing things into the template, but it seems the requirement is for the template to do it all. For instance, the Perl code should remain the same (I imagine it'd be called from a server, but that part of the project is unknown to me), and the template would be processed

I'll check out that library... thanks. I guess this whole thing is to test out the power of Perl/TT before it gets implemented, or more accurately, to see if it's worth it to implement it.

So you're saying the template can't handle that type of processing? I've been dinking around with the 'VIEWS' part of the toolkit, but can't seem to get anything to work correctly.

Replies are listed 'Best First'.
Re: Re: Re: Template Toolkit and XML
by perrin (Chancellor) on Apr 20, 2004 at 22:30 UTC
    Since you can use in-line Perl if you really want to, there is nothing you can do in Perl that you can't do in TT. However, the point of a templating system is to separate your code from your presentation. You want to do processing stuff in perl, where it is most easily expressed, and presentation stuff in TT, where it is most easily expressed.

    The requirement to "do it all" in the template is misguided, and I'd suggest you try to find out who came up with that and why. It will work, but it makes your template more complex and possibly too difficult for a non-programmer to modify.

      Well, that looks like two votes from you guys, and I definately will change that now. My original plan was to parse "X" keys out, and just dump that to the screen... as you both pointed out, that's misguided. So it seems my idea of "one place" is out of line, I'll change this to throw the variables into TT (which I'll be back tomorrow probably ;)

      It just seemed logical to me to separate the data and presentation layers, but now it seems I have two "middlemen", if you will... one .pl to parse the document, and one to present it -- on top of the data layer. I'm actually wondering why I can't just do this in XSL/T (which it seems pretty much what this module is doing) and drop it in that way. The one who suggested it happens to be the boss, and he's not up on Perl/TT that much either. Luckily, he's the type that should listen to reason.

      --DesertGhost

      Thanks to you both... I'll get on this tomorrow and see if that's a bit easier.

        It just seemed logical to me to separate the data and presentation layers

        Right, which is exactly what you are not doing by making your template parse the data and decide what to display.

        I'm actually wondering why I can't just do this in XSL/T

        You probably can. Go for it, if you like XSLT. XML::LibXML is still probably your best bet for that.

Re: Re: Re: Template Toolkit and XML
by iburrell (Chaplain) on Apr 21, 2004 at 00:47 UTC
    What are you trying to do? The template isn't doing the parsing. It is using XML::Simple or XML::DOM to do the parsing. And then doing something with the result.

    I think it makes much more sense to do the parsing outside the template. Then feed to the parsed data, or even the DOM tree, to the template to output.