rcrowe/TwigBridge — pull request #45 by ivannpaz (2013-06-11 22:34:25+00:00)
Title: Make configured functions available in the Twig views.

For your consideration, based on 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...".