Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re^3: Templating system choice

by Your Mother (Archbishop)
on Dec 21, 2020 at 16:48 UTC ( [id://11125535]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Templating system choice
in thread Here documents in blocks

Template::Toolkit (TT) is the most powerful templating language in Perl; well, maybe it’s really Mason, but that is a digression. It’s not necessarily a good thing.

My POV: I love and use Template and have for 15ish years. I don’t use it for new projects. It is complex enough that it becomes a mini-language, so you’re not really doing Perl and you’re not really handing off templates to designers or non-coders that they will be able to understand and edit. It can easily make a clean MVC design into spaghetti soup by embedding all three elements in templates.

Also TT is extremely slow compared to something like Text::Xslate. Xslate has the benefit of being a more pure View. It’s got a few affordances but it doesn’t really rise to the level of mini-language. If you’re using Mojo, its templates might be a better idea than TT.

The only clear advantage I see in learning TT is that many legacy projects use it, so it might be nice to know when job hunting.

Replies are listed 'Best First'.
Re^4: Templating system choice
by GrandFather (Saint) on Dec 21, 2020 at 20:08 UTC

    I went down the HTML::Template path. It's much lighter weight than TT, quicker to learn and with enough built in smarts to get stuff done without needing to embed code.

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

      It’s also much closer to a pure View and as such a good choice for maintenance. The only advantage Xslate has there is speed; it’s in C and additionally optimized to cached templates.

        Xslate has there is speed; it’s in C and additionally optimized to cached templates.

        Well that excludes that option from the choice...complied modules cannot be readily installed on the shared hosting I'm using. I can ask support to install them which is a lottery on who picks up the ticket as to if and when it happens. So it's no for now. Maybe I shall look again when I have VPS or a dedicated server.

Re^4: Templating system choice
by hippo (Bishop) on Dec 21, 2020 at 16:59 UTC
    Also TT is extremely slow compared to something like Text::Xslate.

    That's an interesting observation. I have not noticed it being extremely slow but maybe that's more to do with my use cases and data volumes. Does this extreme slowness still exhibit for you in versions >= 3.0? The changelogs suggest quite a bit of optimisation in that release.


    🦛

      It’s an order of magnitude faster. So TT3 would have to be like 1,000 faster than TT2 to even close most of the gap. If you’re not doing 30+ dynamic requests per second it won’t matter. On a heavy traffic site, 100–10,000+ requests per second it will be the difference between constant outages and transparent service; as long as everything else, like DB, is optimized/cached.

      Update: Template::Alloy already runs older TT syntax much faster and it’s what I have used in the past.

Re^4: Templating system choice
by Bod (Parson) on Dec 21, 2020 at 17:13 UTC
    The only clear advantage I see in learning TT is that many legacy projects use it, so it might be nice to know when job hunting

    It's nearly 2 decades since I was job hunting. I've worked for myself for long enough to know that I don't ever want to work for anyone else again - now things are the other way around as I employ people and have to cope with those challenges instead...

    I love and use Template and have for 15ish years. I don’t use it for new projects.

    This seems strange to me...
    If you love Template and presumably you are very familiar with it from the time you have spent using it, why would you not use it for new projects?

      People are lazy. I am lazy. I gravitate toward what I know as opposed to what will make my future work and maintenance easier. MVC is an excellent rule of thumb; TT makes it trivial to break. Which makes writing new code quick for those handy with it at the expense of sometimes immense, even untenable, technical debt, AKA we need a total rewrite.

      Discipline is hard. Correctness is hard. It pays benefits down the road. Depending. :P There are no actual rules in design, only rules of thumb.

        I'm lazy. I gravitate toward writing what I hope to be clear robust code now to tackle the task at hand without shutting doors as far as reasonable knowing I'll probably come back to it later. I have a friend/co-worker who knows that the first cut of a piece of code is rubbish and expects to completely rewrite it later. He also like to future proof code so adds coding overhead "just in case we need it later". We pay the penalty for that future proofing every tie we touch the code.

        I take longer to get the first cut out, but my code almost never needs a total rewrite and is generally easier to maintain and extend. His future proofing almost never gets used, but is always a maintenance burden. He is often correct in that the first cut of his code generally ends up being replaced or is a maintenance nightmare. Laziness wins, but it has to be the right sort.

        Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond
Re^4: Templating system choice
by Bod (Parson) on Dec 21, 2020 at 19:01 UTC
    Also TT is extremely slow compared to something like Text::Xslate. Xslate has the benefit of being a more pure View.

    Having looked at the documentation for Text::Xslate I see that it is "a template engine, tuned for persistent applications". As I rarely write persistent, or at least persistent applications with enough output to warrant a template, this is probably not the one for my needs.

    Also Template Toolkit seems to have more extensive and clearer documentation and examples. These cover areas beyond just HTML. Web development is just a part of my coding so I think this is where I am going to start. It has also been around long enough that several Monks have become familiar with it so I can hopefully get the guidance I need when I inevitably get stuck 😊

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-26 06:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found