2017 © Pedro Peláez
 

symfony-bundle twig-helper-bundle

Symfony TwigHelper Twig Extension Bundle

image

tangoman/twig-helper-bundle

Symfony TwigHelper Twig Extension Bundle

  • Sunday, April 8, 2018
  • by Tangoman
  • Repository
  • 0 Watchers
  • 0 Stars
  • 95 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 1 % Grown

The README.md

TangoMan TwigHelper Bundle

TangoMan TwigHelper Bundle provides a collection of useful twig functions., (*1)

Installation

Step 1: Download the Bundle

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:, (*2)

$ composer require tangoman/twig-helper-bundle

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation., (*3)

Step 2: Enable Bundle

Then, enable the bundle by adding it to the list of registered bundles in the app/AppKernel.php file of your project:, (*4)

<?php
// app/AppKernel.php

// ...
class AppKernel extends Kernel
{
    // ...

    public function registerBundles()
    {
        $bundles = array(
            // ...
            new TangoMan\TwigHelperBundle\TangoManTwigHelperBundle(),
        );

        // ...
    }
}

Availlable functions

start_with

(deprecated, since twig 3x handles this one just fine), (*5)

Checks if at least one item from haystack starts with needle., (*6)

{% if start_with(app.request.attributes.get('_route'), item.pages ?? []) %}
    {{ item }}
{% endif %}

end_with

(deprecated, since twig 3x handles this one just fine), (*7)

Checks if at least one item from haystack ends with needle., (*8)

{% if end_with(app.request.attributes.get('_route'), ['index','list']) %}
    {{ item }}
{% endif %}

is_numeric

Finds whether a variable is a number or a numeric string., (*9)

{% if is_numeric(item) %}
    {{ item }}
{% else %}
    "{{ item }}"
{% endif %}

is_string

Find whether the type of a variable is string., (*10)

{% if is_string(user) %}
    Welcome {{ user }} !
{% else %}
    Are you kidding me ? Is "{{ user }}" even a name ?
{% endif %}

Availlable filters

to_array

Converts stdObject or json string to traversable array., (*11)

{% for key, value in object|to_array %}
    <td>{{ key }}</td>
    <td>{{ value }}</td>
{% endif %}

Note

If you find any bug please report here : Issues, (*12)

License

Copyright (c) 2020 Matthias Morin, (*13)

License Distributed under the MIT license., (*14)

If you like TangoMan TwigHelper Bundle please star! And follow me on GitHub: TangoMan75 ... And check my other cool projects., (*15)

Matthias Morin | LinkedIn, (*16)

The Versions

08/04 2018

dev-master

9999999-dev

Symfony TwigHelper Twig Extension Bundle

  Sources   Download

The Requires

 

by Matthias Morin

service twig extension bundle symfony tangoman twighelper

08/04 2018

1.0.2

1.0.2.0

Symfony TwigHelper Twig Extension Bundle

  Sources   Download

The Requires

 

by Matthias Morin

service twig extension bundle symfony tangoman twighelper

13/10 2017

1.0.1

1.0.1.0

Symfony TwigHelper Twig Extension Bundle

  Sources   Download

The Requires

 

by Matthias Morin

service twig extension bundle symfony tangoman twighelper

03/10 2017

1.0.0

1.0.0.0

Symfony TwigHelper Twig Extension Bundle

  Sources   Download

The Requires

 

by Matthias Morin

service twig extension bundle symfony tangoman twighelper