2017 © Pedro Peláez
 

library wordpress-twig-helper

Helpers for using Twig with WordPress

image

dsawardekar/wordpress-twig-helper

Helpers for using Twig with WordPress

  • Sunday, July 27, 2014
  • by dsawardekar
  • Repository
  • 1 Watchers
  • 0 Stars
  • 215 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 7 Versions
  • 0 % Grown

The README.md

WordPress Twig Helper Build Status  [![Scrutinizer Code Quality][3]][4]

A tiny Library for using Twig Templates in WordPress Plugins & Themes., (*1)

Usage

The WpTwigHelper\TwigHelper is a helper class that provides the bulk of the functionality., (*2)

First give the TwigHelper a base directory. This will usually correspond to your plugin or theme directory. It must contain a templates sub directory that contains the .twig templates., (*3)

<?php use WpTwigHelper\TwigHelper;

$helper = new TwigHelper();
$helper->setBaseDir(plugin_dir_path(__FILE__));

Then if you have the template hello.twig in the templates directory with the contents,, (*4)

Hello {{ name }}

You can render the template with the render method. It returns the output of rendering the twig template. Use the display method to echo the output instead., (*5)

<?php
$helper->render('hello', array('name' => 'there'));

Precompiling Templates

You can optionally precompile the templates using the provided command line tool, twig_compile. It takes the source directories to compile and the destination to put the compiled twig templates into., (*6)

$ twig_compile -s templates -t dist/templates

This command can be added to your build process., (*7)

By default the TwigHelper looks for compiled templates in the dist/templates directory. If present the Twig compilation phase is skipped. This will speed up rendering of your templates as it's equivalent to using inline PHP., (*8)

When dist/templates is absent caching is turned off instead., (*9)

System Requirements

  • Same as Twig, ie:- PHP 5.3.2+

License

MIT License. Copyright © 2014 Darshan Sawardekar., (*10)

The Versions

27/07 2014

dev-develop

dev-develop http://github.com/dsawardekar/wordpress-twig-helper

Helpers for using Twig with WordPress

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress twig

10/05 2014

dev-master

9999999-dev http://github.com/dsawardekar/wordpress-twig-helper

Helpers for using Twig with WordPress

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress twig

10/05 2014

0.2.0

0.2.0.0 http://github.com/dsawardekar/wordpress-twig-helper

Helpers for using Twig with WordPress

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress twig

10/05 2014

0.1.3

0.1.3.0 http://github.com/dsawardekar/wordpress-twig-helper

Helpers for using Twig with WordPress

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress twig

10/05 2014

0.1.2

0.1.2.0 http://github.com/dsawardekar/wordpress-twig-helper

Helpers for using Twig with WordPress

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress twig

24/04 2014

0.1.1

0.1.1.0 http://github.com/dsawardekar/wordpress-twig-helper

Helpers for using Twig with WordPress

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress twig

24/04 2014

0.1.0

0.1.0.0 http://github.com/dsawardekar/wordpress-twig-helper

Helpers for using Twig with WordPress

  Sources   Download

MIT

The Requires

 

The Development Requires

wordpress twig