2017 © Pedro Peláez
 

library twig-syntax

Write native php templates using a Twig-like syntax

image

aklump/twig-syntax

Write native php templates using a Twig-like syntax

  • Tuesday, October 11, 2016
  • by aklump
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Twig Syntax

Summary

This is an attempt to match Twig syntax in PHP., (*1)

Roadmap

I expect this to grow slowly as I need more functionality; I'm not trying to create a total solution, just bridge a temporary gap., (*2)

Examples 1

Twig

{% set classes = [
  'mi',
  'fa',
  'so',
]|merge(classes) %}

TwigSyntax

$twig = new TwigSyntax;
...
$twig->set(array(
    'mi',
    'fa',
    'so',
))->merge($classes);

The result is that $classes === ['mi', 'fa', 'so', 'do', 're']., (*3)

Vanilla PHP

It is equivalent to:, (*4)

$classes = array_merge(
    array(
        'mi',
        'fa',
        'so',
    ),
    $classes
);

Examples 2

Ensuring that classes/$classes exits, (*5)

Twig

{% set classes = [
  'mi',
  'fa',
  'so',
]|merge(classes|default([])) %}

TwigSyntax

$twig = new TwigSyntax;
...
$classes = isset($classes) ? $classes : array();
$twig->set(array(
    'mi',
    'fa',
    'so',
))->merge($classes);

The Versions

11/10 2016

dev-master

9999999-dev http://github.com/aklump/twig-syntax

Write native php templates using a Twig-like syntax

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.0

 

twig php templates

11/10 2016

0.1

0.1.0.0 http://github.com/aklump/twig-syntax

Write native php templates using a Twig-like syntax

  Sources   Download

BSD-3-Clause

The Requires

  • php >=5.3.0

 

twig php templates