Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re^2: The hidden charm of Template::Toolkit (and templates generally)

by shmem (Chancellor)
on Jan 07, 2008 at 10:41 UTC ( [id://660796]=note: print w/replies, xml ) Need Help??


in reply to Re: The hidden charm of Template::Toolkit (and templates generally)
in thread The hidden charm of Template::Toolkit (and templates generally)

The best reason to use any template language, in any system, is in the readability and functionality a template language brings.

Readability: only if you have a high ratio of static/dynamic code; functionality: only if restricting is a benefit.

The problem is, it doesn't scale. For any HTML entity, any visual reference, it can affect another entity or reference. If I want to apply css, js and what not, I don't have a single document that contains everything in a single view. What's worse is, to find any particular piece, I have to go backwards and figure out what calls what.

What do you mean by 'scaling'? A template doesn't save you from "entities affecting each other". You have a single document only in the case of trivial pages with sparse dynamic content. If you have e.g. inclusions (of other templates), reading gets equally difficult, an you have to go back to look where each bit comes from.

And if you have a different language, e.g. that of Template::Toolkit, you have to go back to the calling code to see what every token means.

[% INCLUDE debugtxt msg="file: $error.info" %]
Quick, was is info here? A hash key, a method, function, something else?

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}
  • Comment on Re^2: The hidden charm of Template::Toolkit (and templates generally)
  • Download Code

Replies are listed 'Best First'.
Re^3: The hidden charm of Template::Toolkit (and templates generally)
by exussum0 (Vicar) on Jan 07, 2008 at 12:47 UTC
    What do you mean by 'scaling'? A template doesn't save you from "entities affecting each other". You have a single document only in the case of trivial pages with sparse dynamic content. If you have e.g. inclusions (of other templates), reading gets equally difficult, an you have to go back to look where each bit comes from.
    By scaling I mean, you start out w/ HTML (or text) and you add logic to it. Some pages will be horridly complex and things start to get messy, sure, as we go off to infinity. Point is, you start off w/ a document and start to add the logic. If there's very little, the template looks pretty much like what you started w/. Doing it as code, it starts out as something highly unreadable, and it takes diligence to make it not look like a mess.

    And yes, I can include to death, but I shouldn't be using goto, i mean spaghetti code, I mean includes except as a matter of large scale convenience.

    In the end, I could throw it all away and say it really doesn't matter. It's all turing complete and equivalent. You can create the same mess in any fashion. It's the starting point and the usability of the tech that a) promotes a certain type of usage and b) gives you a good starting point. For template languages it's, start off w/ large documents and then make them dynamic. It's not, take something dynamic and make it output HTML.

    Same holds true for other things. SQL is equivalent by using hashsets and mutex locks to mimic the behaviour, but hell, I'll make people cry doing that. I can probably do business logic in PL/SQL or TransactSQL, but that's not very nice either.

    As for tokens meaning something, I hope you are using variables in templates that mean something. I hope there's documentation, be it wireframe or graphical mockups. :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://660796]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2024-04-25 04:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found