2017 © Pedro Peláez
 

library zend-expressive-twigrenderer

Twig integration for Expressive

image

zendframework/zend-expressive-twigrenderer

Twig integration for Expressive

  • Monday, April 9, 2018
  • by zendframework
  • Repository
  • 19 Watchers
  • 19 Stars
  • 78,195 Installations
  • PHP
  • 16 Dependents
  • 3 Suggesters
  • 17 Forks
  • 0 Open issues
  • 22 Versions
  • 12 % Grown

The README.md

Twig Integration for Expressive

Repository abandoned 2019-12-31

This repository has moved to mezzio/mezzio-twigrenderer., (*1)

Build Status Coverage Status, (*2)

Provides Twig integration for Expressive., (*3)

Installation

Install this library using composer:, (*4)

$ composer require zendframework/zend-expressive-twigrenderer

We recommend using a dependency injection container, and typehint against container-interop. We can recommend the following implementations:, (*5)

Twig Extension

The included Twig extension adds support for url generation. The extension is automatically activated if the UrlHelper and ServerUrlHelper are registered with the container., (*6)

  • path: Render the relative path for a given route and parameters. If there is no route, it returns the current path., (*7)

    {{ path('article_show', {'id': '3'}) }}
    Generates: /article/3
    

    path supports optional query parameters and a fragment identifier., (*8)

    {{ path('article_show', {'id': '3'}, {'foo': 'bar'}, 'fragment') }}
    Generates: /article/3?foo=bar#fragment
    

    By default the current route result is used where applicable. To disable this the reuse_result_params option can be set., (*9)

    {{ path('article_show', {}, {}, null, {'reuse_result_params': false}) }}
    
  • url: Render the absolute url for a given route and parameters. If there is no route, it returns the current url., (*10)

    {{ url('article_show', {'slug': 'article.slug'}) }}
    Generates: http://example.com/article/article.slug
    

    url also supports query parameters and a fragment identifier., (*11)

    {{ url('article_show', {'id': '3'}, {'foo': 'bar'}, 'fragment') }}
    Generates: http://example.com/article/3?foo=bar#fragment
    

    By default the current route result is used where applicable. To disable this the reuse_result_params option can be set., (*12)

    {{ url('article_show', {}, {}, null, {'reuse_result_params': false}) }}
    
  • absolute_url: Render the absolute url from a given path. If the path is empty, it returns the current url., (*13)

    {{ absolute_url('path/to/something') }}
    Generates: http://example.com/path/to/something
    
  • asset Render an (optionally versioned) asset url., (*14)

    {{ asset('path/to/asset/name.ext', version=3) }}
    Generates: path/to/asset/name.ext?v=3
    

    To get the absolute url for an asset:, (*15)

    {{ absolute_url(asset('path/to/asset/name.ext', version=3)) }}
    Generates: http://example.com/path/to/asset/name.ext?v=3
    

Configuration

If you use the zend-component-installer the factories are configured automatically for you when requiring this package with composer. Without the component installer, you need to include the ConfigProvider in your config/config.php. Optional configuration can be stored in config/autoload/templates.global.php., (*16)

'templates' => [
    'extension' => 'file extension used by templates; defaults to html.twig',
    'paths' => [
        // namespace / path pairs
        //
        // Numeric namespaces imply the default/main namespace. Paths may be
        // strings or arrays of string paths to associate with the namespace.
    ],
],
'twig' => [
    'cache_dir' => 'path to cached templates',
    'assets_url' => 'base URL for assets',
    'assets_version' => 'base version for assets',
    'extensions' => [
        // extension service names or instances
    ],
    'runtime_loaders' => [
        // runtime loaders names or instances   
    ],
    'globals' => [
        // Global variables passed to twig templates
        'ga_tracking' => 'UA-XXXXX-X'
    ],
    'timezone' => 'default timezone identifier, e.g.: America/New_York',
    'optimizations' => -1, // -1: Enable all (default), 0: disable optimizations
    'autoescape' => 'html', // Auto-escaping strategy [html|js|css|url|false]
    'auto_reload' => true, // Recompile the template whenever the source code changes
    'debug' => true, // When set to true, the generated templates have a toString() method
    'strict_variables' => true, // When set to true, twig throws an exception on invalid variables
],

Documentation

See the Expressive Twig documentation., (*17)

The Versions

09/04 2018

dev-develop

dev-develop

Twig integration for Expressive

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

middleware psr psr-7 twig http zendframework zf expressive zend-expressive

09/04 2018

dev-master

9999999-dev

Twig integration for Expressive

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

middleware psr psr-7 twig http zendframework zf expressive zend-expressive

09/04 2018
15/03 2018
01/02 2016

1.1.1

1.1.1.0

Twig integration for Expressive

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

middleware psr psr-7 twig http expressive

21/01 2016

1.1.0

1.1.0.0

Twig integration for Expressive

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

middleware psr psr-7 twig http expressive

21/01 2016

1.0.1

1.0.1.0

Twig integration for Expressive

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

middleware psr psr-7 twig http expressive

07/12 2015

1.0.0

1.0.0.0

Twig integration for Expressive

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

middleware psr psr-7 twig http expressive

03/12 2015

0.3.1

0.3.1.0

Twig integration for Expressive

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

middleware psr psr-7 twig http expressive

02/12 2015

0.3.0

0.3.0.0

Twig integration for Expressive

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

middleware psr psr-7 twig http expressive

10/11 2015

0.2.1

0.2.1.0

Twig integration for Expressive

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

middleware psr psr-7 twig http expressive

20/10 2015

0.2.0

0.2.0.0

Twig integration for Expressive

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

middleware psr psr-7 twig http expressive

11/10 2015

0.1.1

0.1.1.0

Twig integration for Expressive

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

middleware psr psr-7 twig http expressive

11/10 2015

0.1.0

0.1.0.0

Twig integration for Expressive

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

middleware psr psr-7 twig http expressive