in reply to Templating system choice
in thread Here documents in blocks

There is indeed a range of templating modules and this is a good thing because one size does not necessarily fit all. I am happy with Template and would choose it again if starting from scratch because it has everything I need with very few downsides. It has a steeper learning curve that many of the alternatives, but the docs are good and a novice can still construct fairly simple but effective templates using it. It is well maintained, suitable for any output format (HTML, CSV, XML, JSON, plain text, LaTeX source, SVG, you name it), comes with command-line utilities (ttree, tpage) and is widely used.


🦛

Replies are listed 'Best First'.
Re^2: Templating system choice
by Bod (Parson) on Dec 21, 2020 at 11:03 UTC

    Thanks hippo. It does seem to me that, whilst Template is powerful and does many things, the documentation is quite clear. Having read the tutorial last evening, I am quite sure I could make it do something useful today.

    Unlike Mojolicious, Template seems more general purpose and not specifically intended for web deployment.

    Template is also already installed on my shared hosting :)

      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.

        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
        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.


        🦛

        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?

        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 😊

      AFAIK does Mojolicious have a default template engine, but allows to plugin any other.

      I'd wet my feet with Mojo first, then you'll know better which direction you wanna swim.

      Cheers Rolf
      (addicted to the Perl Programming Language :)
      Wikisyntax for the Monastery

Re^2: Templating system choice
by Bod (Parson) on Dec 29, 2020 at 00:12 UTC
    I am happy with Template and would choose it again if starting from scratch because it has everything I need with very few downsides

    This evening I've made a start with Template and it was easier to get something working than I expected. It all just seems to fit together nicely.

    Thanks hippo and everyone else who directed me down the templating path.