lablog/stringy

Installs: 13

Dependents: 0

Watchers: 1

Language: PHP

1.0.1 2014-03-07 18:26 UTC

README

A simple plugin for Lablog (or twig stand-alone).

Navigation

Installation

Installation is done via composer packages.

To install, simply add the following to your composer.json file.

...
"require": {
    ...
    "lablog/stringy": "1.0.*"
    ...
}
...

Laravel & LaBlog Usage

To use the stringy filters with Laravel 4 and LaBlog, just add the service provider to your app/config/app.php providers list.

Note: The provider must be added after the Laravel 4 Twig Bridge provider. Note2: If you have LaBlog up and running, you will have already added the Twig Bridge provider.

...
    'Lablog\Stringy\StringyServiceProvider'
...

Using with Stand-alone Twig

To use the stringy filters with a stand-along, non-laravel bridged twig, just add the following to your twig extensions.

'Lablog\Stringy\Twig\StringyLoader'

Note: This has *not** been tested!*

General Usage in Templates

To use the stringy filters in a template, simply use the name of any of the stringy functions as a filter.

<!-- Other Code -->
    <!-- Ensure the string has http:// to the left. -->
    {{ string | ensureLeft('http://') }}
    <!-- Output the 6th character of the string, starting from 0. -->
    {{ string | at(6) }}
<!-- Other Code -->

Please see the official twig github page for a full list of functions.