About Twig Template Engine Output

Allows you to easily use the Twig Templating Engine for output.

Category 1Markup Generation
Markup modules that are called upon to generate or parse markup (like HTML). Markup modules are most often used on the front-end of a site (rather than admin).
Category 2Other Modules
Modules that have a unique purpose not covered by existing categories.
Release StateBeta
Close to stable, but users are advised to be cautious and test thoroughly.*
Authorporl
Module Version1.0.2
Class NameTemplateTwig
Compatibility2.2
Date AddedAugust 5, 2012
Last UpdatedAugust 4, 2012
Recommended ByNew recommendations may take up to 1 day to appear.

Details

Allows you to easily use the Twig Templating Engine for output.
See here for details.

Instructions

Note: Marcostoll has made a much more advanced module which does pretty much everything that this module can do. I recommend you use his one here.

  • Copy TemplateTwig directory to site/modules
  • Ensure http daemon has write access to site/assets/cache dir (this should be the case anyway)
  • Copy templates directory to site (this contains some sample Twig templates and views)
    Note: By default these templates overwrite the standard site-default ones to use twig. If you don't want
    this then just create the templates and templates/views directories and use the ones from here as a guide
    to make your own.
  • Enable TemplateTwig module in ProcessWire
  • Create pages that use the twig templates.
    NOTE: As Twig handles html escaping etc itself, you can usually remove any htmlspecialchars filters from
    your fields. If you don't do this you may run into double-escaping issues.

README

TemplateTwig

Adds a Twig render method to Page
For more information on Twig visit http://twig.sensiolabs.org/
Copyright (C) 2012 by Paul Sheean porl42@gmail.com
Licensed under GNU/GPL v2, see LICENSE.txt
For Twig license see LICENSE.twig.txt

Installation

  • Copy TemplateTwig directory to site/modules

  • Enable TemplateTwig module in ProcessWire

  • Ensure module configuration (paths etc) is correct.

  • Your templates now have access to a twig parameter that can be used as follows:

      $variables = array("foo" => "bar", "hello" => "world);
      echo $page->twig->render('basic-page.html.twig', $variables);

    The templates directory with this module contains sample Twig templates and views
    that recreate the standard site-default templates with Twig. If you don't want to use
    them then just create the templates/views directory and use the files from here
    as a guide to make your own.

  • Create pages that use the twig templates.
    NOTE: As Twig handles html escaping etc itself, you can usually remove any htmlspecialchars filters from your fields.If you don't do this you may run into double-escaping issues.

Comments

No comments yet. Be the first to post!

Post a Comment

Your e-mail is kept confidential and not included with your comment. Website is optional.