in reply to Generation of dynamically-static documents

Template::Toolkit seems better suited for such venture. The Badger Book has several chapters on making such "static" websites directly from templates: see Chapter 2.

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

  • Comment on Re: Generation of dynamically-static documents

Replies are listed 'Best First'.
Re^2: Generation of dynamically-static documents
by Tanktalus (Canon) on Sep 11, 2005 at 22:20 UTC

    I'm not sure I follow how having a script invoke Template::Toolkit via some custom logic to produce the data is any different than HTML::Template. In fact, I am unsure that the choice of templating system (is this the View in MVC?) is significant here, unless it's in conjunction with the underlying Controller which is dependant on some templating system to work.

    I'm even less clear on how TT will help keep a single set of code with as little redundancy as possible between a static site and a CGI-based site in producing the same end-result for the browser. (The href changes I mentioned above are still the same end-result in that the links work, not that they're identical markup.)

      TT2 is quite separate from any MVC-system (although it plays very nice with Catalyst). You could run TT2 outside of a web-server (there is the ttree.pl script to do so) and it would generate all your html-pages at once -- and would even do so without re-generating the pages which remain unchanged) or run it in your web-server (CGI or mod-perl enabled Apache for instance) and the requested page(s) will be made on-the-fly.

      Perhaps that is also possible with HTML::Template, but I like TT2 more. YMMV.

      CountZero

      "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

      I'm not sure I follow how having a script invoke Template::Toolkit via some custom logic to produce the data is any different than HTML::Template

      Sure, you can do it with HTML::Template too - but TT2 has some built in tools to make the process easier. Tools like Template::Tools::ttree (comes with TT2) and Template::TT2Site will automatically generate a static copy of a TT2 site if set up appropriately. So you can have dynamically generated content on your dev site, with an appropriate ttree/rsync combo in your makefile to shift a static version of your site to the production server.

        I'm trying to figure out how ttree or TT2Site is going to figure out what code to run as part of each template. For example, one page is a list of officers in the group. So, I need to query the officers "table" via DBD::CSV, ordered by a certain value. Another page is a list of activities, grouped by month. So I need to query the activities "table", ordered and grouped - and I need to figure out the current date and only get the activities in the current "activity year" (related to the school year - starts in September). Another page is a list of these activities with descriptions and the person who runs them, which is sometimes tied to the officers. So here's a query against a couple of tables.

        These queries are already done, and they work. I just need to tie them in to the templates and either generate them statically or dynamically, depending on context. And I figured that with perl's great use of context, this would be a perfect fit ... somewhere. ;-)

        And putting code of any sort into the template wasn't exactly what I was hoping for.