NAME Solution - A Simple, Stateless Template System Synopsis use Solution; my $template = Solution::Template->new( ); $template->parse( # See Solution::Tag for more '{%for x in (1..3) reversed %}{{x}}, {%endfor%}{{some.text}}' ); print $template->render( { some => { text => 'Contact!' } } ); Description Solution is a template engine based on Liquid. The Liquid template engine was crafted for very specific requirements: * It has to have simple markup and beautiful results. Template engines which don't produce good looking results are no fun to use. * It needs to be non-evaling and secure. Liquid templates are made so that users can edit them. You don't want to run code on your server which your users wrote. * It has to be stateless. The compile and render steps have to be separate, so that the expensive parsing and compiling can be done once; later on, you can just render it by passing in a hash with local variables and objects. * It needs to be able to style emails as well as HTML. Getting Started It's very simple to get started with Solution. Just as in Liquid, templates are built and used in two steps: Parse and Render. For an overview of the Liquid/Solution syntax, please read Liquid for Designers (it's linked to in the See Also section below). # Parses and compiles the template my $template = Solution::Template->parse('Hi, {{name}}!'); # Renders the output => "Hi, Sanko!" $template->render({ name => 'Sanko' }); The "parse" step creates a fully compiled template which can be re-used as often as you like. You can store it in memory or in a cache for faster rendering later. All parameters you want Solution to work with have to be passed as parameters to the render method. Solution is a closed ecosystem; it does not know about your local, instance, and global variables. For more, see Solution::Tag. Why should I use Solution? * You want to allow your users to edit the appearance of your application, but don't want them to run insecure code on your server. * You want to render templates directly from the database. * You like Smarty-style template engines. * You need a template engine which does HTML just as well as emails. * You don't like the markup language of your current template engine. * You wasted three days reinventing this wheel when you could have been doing something productive like volunteering or catching up on past seasons of *Doctor Who*. Why shouldn't I use Solution? * You've found or written your own template engine which fills your needs better than Liquid or Solution ever could. Psst! Hey, if you haven't found it yet, check the See Also section. * You are uncomfortable with text that you didn't copy and paste yourself. Everyone knows computers cannot be trusted. Ugh! Why a new Top Level Namespace? I really don't have a good reason but I promise to send myself to bed without dinner as punishment. As I understand it, the original project's name, Liquid, is a reference to the classical states of matter (the engine itself being stateless). I settled on Solution because it's Liquid but... with... bits of other stuff floating in it. Pretend you majored in chemistry instead of mathematics or computer science and you'll know what I mean. This 'solution' is not the answer to all your problems. ...I'll even go ahead and say it's not the best solution for your templating problems. It's simply *a* solution. See Also Liquid for Designers: http://wiki.github.com/tobi/liquid/liquid-for-designers Solution::Tag's docs on custom filter creation Other Template Engines * The Template Toolkit is the granddaddy of all Perl based template engines. * ...which would make Template::Tiny the weird uncle. *Note: This list is obviously incomplete.* Author Sanko Robinson - http://sankorobinson.com/ The original Liquid template system was developed by jadedPixel (http://jadedpixel.com/) and Tobias Lütke (http://blog.leetsoft.com/). License and Legal Copyright (C) 2009,2010 by Sanko Robinson This program is free software; you can redistribute it and/or modify it under the terms of The Artistic License 2.0. See the LICENSE file included with this distribution or http://www.perlfoundation.org/artistic_license_2_0. For clarification, see http://www.perlfoundation.org/artistic_2_0_notes. When separated from the distribution, all original POD documentation is covered by the Creative Commons Attribution-Share Alike 3.0 License. See http://creativecommons.org/licenses/by-sa/3.0/us/legalcode. For clarification, see http://creativecommons.org/licenses/by-sa/3.0/us/.