2017 © Pedro Peláez
 

library twital

PHP templating engine that combines Twig and PHPTal power points

image

goetas/twital

PHP templating engine that combines Twig and PHPTal power points

  • Thursday, June 14, 2018
  • by goetas
  • Repository
  • 9 Watchers
  • 99 Stars
  • 3,325 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 12 Forks
  • 2 Open issues
  • 18 Versions
  • 4 % Grown

The README.md

Build Status Scrutinizer Quality Score Code Coverage GitHub license Packagist, (*1)

What is Twital?

Twital is a template engine built on top of Twig (a template engine for PHP and default template engine on Symfony) that adds some shortcuts and makes Twig's syntax more suitable for HTML based (XML, HTML5, XHTML, SGML) templates. Twital takes inspiration from PHPTal, TAL and AngularJS or Vue.js (just for some aspects), mixing their language syntaxes with the powerful Twig templating engine system., (*2)

Twital is fully compatible with Twig, all Twig templates can be rendered using Twital., (*3)

To better understand the Twital's benefits, consider the following Twital template, which simply shows a list of users from an array:, (*4)

<ul t:if="users">
    <li t:for="user in users">
        {{ user.name }}
    </li>
</ul>

To do the same thing using Twig, you need:, (*5)

{% if users %}
    <ul>
        {% for user in users %}
            <li>
                {{ user.name }}
            </li>
        {% endfor %}
    </ul>
{% endif %}

As you can see, the Twital template is more readable, less verbose and and you don't have to worry about opening and closing block instructions (they are inherited from the HTML structure)., (*6)

One of the main advantages of Twital is the implicit presence of control statements, which makes templates more readable and less verbose. Furthermore, it has all Twig functionalities, such as template inheritance, translations, looping, filtering, escaping, etc., (*7)

If some Twig functionality is not directly available for Twital, you can freely mix Twig and Twital syntaxes., (*8)

In the example below, we have mixed Twital and Twig syntaxes to use Twig custom tags:, (*9)

<h1 t:if="users">
    {% custom_tag %}
        {{ someUnsafeVariable }}
    {% endcustom_tag %}
</h1>

When needed, you can extend from a Twig template:, (*10)

<t:extends from="layout.twig">

    <t:block name="content">
        Hello {{name}}!
    </t:block>

</t:extends>

You can also extend from Twig a Twital template:, (*11)

{% extends "layout.twital" %}

{% block content %}
    Hello {{name}}!
{% endblock %}


A presentation of Twital features and advantages is available on this presentation., (*12)

Installation

The recommended ways install Twital is via Composer., (*13)

composer require goetas/twital

Documentation

Go here http://twital.readthedocs.org/ to read a more detailed documentation about Twital., (*14)

Getting started

First, you have to create a file that contains your template (named for example demo.twital.html):, (*15)

<div t:if="name">
    Hello {{ name }}
</div>

Afterwards, you have to create a PHP script that instantiate the required objects:, (*16)

require_once '/path/to/composer/vendor/autoload.php';
use Goetas\Twital\TwitalLoader;

$fileLoader = new Twig_Loader_Filesystem('/path/to/templates');
$twitalLoader = new TwitalLoader($fileLoader);

$twig = new Twig_Environment($twitalLoader);
echo $twig->render('demo.twital.html', array('name' => 'John'));

That's it!, (*17)

Symfony Users

If you are a Symfony user, you can add Twital to your project using the TwitalBundle., (*18)

The bundle integrates all most common functionalities as Assetic, Forms, Translations, Routing, etc., (*19)

Twig Users

Starting from version Twital 1.0.0, both twig 1.x and 2.x versions are supported., (*20)

Note

The code in this project is provided under the MIT license. For professional support contact goetas@gmail.com or visit https://www.goetas.com, (*21)

The Versions

14/06 2018

dev-master

9999999-dev https://github.com/goetas/twital

PHP templating engine that combines Twig and PHPTal power points

  Sources   Download

MIT

The Requires

 

The Development Requires

by Asmir Mustafic

templating twig php xml

14/06 2018

v1.2.0

1.2.0.0 https://github.com/goetas/twital

PHP templating engine that combines Twig and PHPTal power points

  Sources   Download

MIT

The Requires

 

The Development Requires

by Asmir Mustafic

templating twig php xml

04/03 2018

v1.1.0

1.1.0.0 https://github.com/goetas/twital

PHP templating engine that combines Twig and PHPTal power points

  Sources   Download

MIT

The Requires

 

The Development Requires

by Asmir Mustafic

templating twig php xml

28/02 2018

v1.0.3

1.0.3.0 https://github.com/goetas/twital

PHP templating engine that combines Twig and PHPTal power points

  Sources   Download

MIT

The Requires

 

The Development Requires

by Asmir Mustafic

templating twig php xml

14/02 2017

v1.0.2

1.0.2.0 https://github.com/goetas/twital

PHP templating engine that combines Twig and PHPTal power points

  Sources   Download

MIT

The Requires

 

The Development Requires

by Asmir Mustafic

templating twig php xml

13/01 2017

v1.0.1

1.0.1.0 https://github.com/goetas/twital

PHP templating engine that combines Twig and PHPTal power points

  Sources   Download

MIT

The Requires

 

The Development Requires

by Asmir Mustafic

templating twig php xml

13/01 2017

dev-html-failure

dev-html-failure https://github.com/goetas/twital

PHP templating engine that combines Twig and PHPTal power points

  Sources   Download

MIT

The Requires

 

The Development Requires

by Asmir Mustafic

templating twig php xml

06/01 2017

v1.0.0

1.0.0.0 https://github.com/goetas/twital

PHP templating engine that combines Twig and PHPTal power points

  Sources   Download

MIT

The Requires

 

The Development Requires

by Asmir Mustafic

templating twig php xml

20/03 2016

0.1.9

0.1.9.0 https://github.com/goetas/twital

PHP templating engine that combines Twig and PHPTal power points

  Sources   Download

MIT

The Requires

 

The Development Requires

by Asmir Mustafic

templating twig php xml

08/08 2015

0.1.8

0.1.8.0 https://github.com/goetas/twital

PHP templating engine that combines Twig and PHPTal power points

  Sources   Download

MIT

The Requires

 

The Development Requires

by Asmir Mustafic

templating twig php xml

13/06 2015

0.1.7

0.1.7.0 https://github.com/goetas/twital

PHP templating engine that combines Twig and PHPTal power points

  Sources   Download

MIT

The Requires

 

The Development Requires

by Asmir Mustafic

templating twig php xml

31/07 2014

0.1.6

0.1.6.0 https://github.com/goetas/twital

PHP templating engine that combines Twig and PHPTal power points

  Sources   Download

MIT

The Requires

 

The Development Requires

by Asmir Mustafic

templating twig php xml

24/07 2014

0.1.5

0.1.5.0 https://github.com/goetas/twital

PHP templating engine that combines Twig and PHPTal power points

  Sources   Download

MIT

The Requires

 

The Development Requires

by Asmir Mustafic

templating twig php xml

29/05 2014

0.1.4

0.1.4.0 https://github.com/goetas/twital

PHP templating engine that combines Twig and PHPTal power points

  Sources   Download

MIT

The Requires

 

The Development Requires

by Asmir Mustafic

templating twig php xml

22/05 2014

0.1.3

0.1.3.0 https://github.com/goetas/twital

PHP templating engine that combines Twig and PHPTal power points

  Sources   Download

MIT

The Requires

 

The Development Requires

by Asmir Mustafic

templating twig php xml

20/05 2014

0.1.2

0.1.2.0 https://github.com/goetas/twital

PHP templating engine that combines Twig and PHPTal power points

  Sources   Download

MIT

The Requires

 

The Development Requires

by Asmir Mustafic

templating twig php xml

08/04 2014

0.1.1-beta

0.1.1.0-beta https://github.com/goetas/twital

Twig templating engine

  Sources   Download

MIT

The Requires

 

The Development Requires

by Asmir Mustafic

templating twig php xml

02/04 2014

0.1.0-beta

0.1.0.0-beta https://github.com/goetas/twital

Twig templating engine

  Sources   Download

MIT

The Requires

 

The Development Requires

by Asmir Mustafic

templating twig php xml