2017 © Pedro Peláez
 

library twig

Twig descendants

image

b2r/twig

Twig descendants

  • Monday, March 27, 2017
  • by b2r
  • Repository
  • 1 Watchers
  • 0 Stars
  • 20 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Twig composition, (*1)

Build Status, (*2)

Features

  • Fluent interface
  • Smart loader
  • Context container

Simple Usage

use b2r\Component\Twig\Twig;

$twig = new Twig();

echo $twig
    ->template('hello', 'Hello, {{ name }}') // Define 'hello' template and 'hello' as current template
    ->name('world') // Set name context
    ; #=>'Hello, world' invoke __toString()

With template, filter, function, global

use b2r\Component\Twig\Twig;

$twig = new Twig(__DIR__ . '/templates');

$twig->addSuffix('.twig');

$twig->addFilters([
    'l' => function ($value) {
        return strtolower($value);
    },
    'u' => function ($value) {
        return strtoupper($value);
    },
]);

$twig->addFunctions([
    'x2' => function ($value) {
        return $value * 2;
    },
]);

$twig->addGlobals([
    'foo' => 'FOO',
    'bar' => 'BAR',
    'baz' => 'BAZ',
]);

echo $twig->template('hello')->name('world');

hello.twig, (*3)

Hello, {{ name }}
Hello, {{ name|u }}
Hello, {{ name|l }}
Hello, {{ foo }}
Hello, {{ bar }}
Hello, {{ baz }}
Score: {{ x2(100) }}

outputs, (*4)

Hello, world
Hello, WORLD
Hello, world
Hello, FOO
Hello, BAR
Hello, BAZ
Score: 200

Docs

The Versions

27/03 2017

dev-master

9999999-dev https://github.com/b2r/php-twig

Twig descendants

  Sources   Download

MIT

The Requires

 

by Avatar b2r

twig template

27/03 2017

v0.2.1

0.2.1.0 https://github.com/b2r/php-twig

Twig descendants

  Sources   Download

MIT

The Requires

 

by Avatar b2r

twig template

27/03 2017

v0.2.0

0.2.0.0 https://github.com/b2r/php-twig

Twig descendants

  Sources   Download

MIT

The Requires

 

by Avatar b2r

twig template

13/03 2017

v0.1.0

0.1.0.0 https://github.com/b2r/php-twig

Twig descendants

  Sources   Download

MIT

The Requires

 

by Avatar b2r

twig template