2017 © Pedro Peláez
 

library twig-validator-extension

A Twig extension to validate objects inside a Twig template

image

polifonic/twig-validator-extension

A Twig extension to validate objects inside a Twig template

  • Thursday, June 15, 2017
  • by opichon
  • Repository
  • 2 Watchers
  • 3 Stars
  • 6,944 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Twig Validator Extension

A simple Twig extension that adds a valid filter to be used in twig templates., (*1)

With this filter you can test if objects are valid inside a twig template and generate the appropriate markup based on the result., (*2)

Installation

Add the package to your app's composer.json:, (*3)

``` json "require": {, (*4)

    "polifonic/twig-validator-extension": "^1.0",
}

### As a Twig Extension Create an instance of `TwigValidatorExtension` and add it to the Twig environment just like any other twig extension. The `TwigValidatorExtension` constructor needs to be passed a validator (an instance of `Symfony\Component\Validator\Validator\ValidatorInterface`). ``` php use Polifonic\Twig\Extension\Validator\TwigValidatorExtension; $validator = ...; $twig = new Twig_Environment($loader); $twig->addExtension(new TwigValidatorExtension($validator));

As a Symfony bundle

The package includes a Symfony bundle named TwigValidatorBundle. This bundle will automatically add the TwigValidatorExtension to twig., (*5)

Enable the TwigValidatorBundle symfony bundle by adding it to your app's kernel:, (*6)

``` php, (*7)

app/AppKernel.php

public function regsiterBundles() { $bundles = array( ... new Polifonic\Twig\Extension\Validator\Symfony\TwigValidatorBundle(), ); }, (*8)



Usage ----- ``` twig {% if object|valid %}...{% endif %}

With validation groups:, (*9)

``` twig {% if object|valid([ "group1", "group2" ]) %}...{% endif %}, (*10)

```, (*11)

The Versions

15/06 2017

dev-master

9999999-dev https://github.com/polifonic/twig-validator-extension

A Twig extension to validate objects inside a Twig template

  Sources   Download

MIT

The Requires

 

The Development Requires

twig validator symfony

04/11 2016

1.0.3

1.0.3.0 https://github.com/polifonic/twig-validator-extension

A Twig extension to validate objects inside a Twig template

  Sources   Download

MIT

The Requires

 

The Development Requires

twig validator symfony

29/10 2016

1.0.2

1.0.2.0 https://github.com/polifonic/twig-validator-extension

A Twig extension to validate objects inside a Twig template

  Sources   Download

MIT

The Requires

 

The Development Requires

twig validator symfony

26/10 2016

1.0.1

1.0.1.0 https://github.com/polifonic/twig-validator-extension

A Twig extension to validate objects inside a Twig template

  Sources   Download

MIT

The Requires

 

The Development Requires

twig validator symfony

26/10 2016

1.0.0

1.0.0.0 https://github.com/polifonic/twig-validator-extension

A Twig extension to validate objects inside a Twig template

  Sources   Download

MIT

The Requires

 

The Development Requires

twig validator symfony