rcrowe/TwigBridge — pull request #48 by ivannpaz (2013-07-05 19:57:28+00:00)
Title: Feature - Expose Functions (calling laravel 4 helpers methods in view)

Regarding: https://github.com/rcrowe/TwigBridge/issues/42

This allows the user to specify functions (for instance laravel helpers) that should be made available to the Twig Views.

```php
'functions' => array(
'base_path',
'app_path',
'camel_case',
)
```

This configuration would make these three functions available to the views as:

```php
{{ base_path() }}
{{ app_path() }}
{{ camel_case("snake_case_incoming") }}
```

Also possible to specify a Closure callback directly:

```php
'functions' => array(
'bond' => function($name, $lastname) {
return "My name is {$lastname}, {$name} {$lastname}...";
},
)
```

And later in the view:

```php
{{ bond("Rob", "Crowe") }}
```
For a dramatic "My name is Crowe, Rob Crowe...".