2017 © Pedro PelĆ”ez
 

library twig-extensions-joomla

Twig - Joomla Framework Language bridge

image

piotr-cz/twig-extensions-joomla

Twig - Joomla Framework Language bridge

  • Saturday, April 26, 2014
  • by mikoweb
  • Repository
  • 3 Watchers
  • 5 Stars
  • 29 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 1 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Twig Extensions - Joomla Framework Build Status

Extensions provide filters to allow using of Joomla-Framework packages such as [Language package][3] in Twig templates., (*1)

Installation

Add "piotr-cz/twig-extensions-joomla": "~1.0" to require block in your composer.json and run composer install., (*2)

{
    "require": {
        "piotr-cz/twig-extensions-joomla": "~1.0"
    }
}

Text extension

It's assumed that you will use Composer to handle autoloading., (*3)

Setup

Add the extension to the twig environment:, (*4)

// Configure Twig
$loader = new \Twig_Loader_Filesystem(JPATH_TEMPLATES);
$twig = new \Twig_Environment($loader, $options = array());

// Register Extension
$twig->addExtension(new \TwigJoomla\Extension\TextExtension);

// Render Template
$template = $twig->loadTemplate('test.twig');
echo $template->render();

Usage

Extension is able to call any public method of Text (like Text::_(), Text::sprintf(), ...)., (*5)

Accepted Parameters, (*6)

  • $method Text method
  • Text arguments

The _ method (default)

Twig Template:, (*7)

{{ "IMADEIT" | jtext }}

Language file:, (*8)

IMADEIT     = "I made it!"

Result:, (*9)

I made it!

The sprintf method

Twig template, (*10)

{{ "HELLOW" | jtext('sprintf', 'World') }}

Language file, (*11)

HELLOW      ="Hello %s!"

Result, (*12)

Hello World!

Date extension

This extension allows to use localised date output and instead of PHP intl extension uses [Language package][3]. Crucial functions imported from of JDate package., (*13)

Setup

$twig->addExtension(new \Twigoomla\Extension\DateExtension($config->get('timezone')));

Usage

Accepted Parameters, (*14)

  • $format DateTime Format
  • $timezone String or DateTimeZone object (optional)

Twig template, (*15)

{{ event.on | jdate('l, j. F Y') }}

Language File, (*16)

SUNDAY      ="neděle"
JUNE        ="červen"

Result, (*17)

neděle, 1. červen 2014

Application setup

See [Joomla-Framework/Language][3] package for instructions on how to setup the Language package in your application., (*18)

Running tests

$ composer install
$ phpunit

Licence

This extensions are released under the MIT License, except Date extension which is released under GPL2, (*19)

The Versions

26/04 2014

dev-master

9999999-dev https://github.com/piotr-cz/Twig-extensions-Joomla

Twig - Joomla Framework Language bridge

  Sources   Download

MIT GPL-2.0+

The Requires

 

language twig i18n joomla

26/04 2014

v1.1.1

1.1.1.0 https://github.com/piotr-cz/Twig-extensions-Joomla

Twig - Joomla Framework Language bridge

  Sources   Download

MIT GPL-2.0+

The Requires

 

language twig i18n joomla

19/04 2014

v1.1.0

1.1.0.0 https://github.com/piotr-cz/Twig-extensions-Joomla

Twig - Joomla Framework Language bridge

  Sources   Download

MIT GPL-2.0+

The Requires

 

language twig i18n joomla

16/04 2014

1.0.0

1.0.0.0 https://github.com/piotr-cz/Twig-extensions-Joomla

Twig - Joomla Framework Language bridge

  Sources   Download

LGPL-2.1+

The Requires

 

language twig i18n joomla

16/04 2014

0.4.1

0.4.1.0 https://github.com/piotr-cz/Twig-extensions-Joomla

Twig - Joomla Framework Language bridge

  Sources   Download

LGPL-2.1+

The Requires

 

language twig i18n joomla