Skip to content
This repository has been archived by the owner on Oct 29, 2024. It is now read-only.

Commit

Permalink
Merge pull request #5 from smartive/feature/remove-non-standard-helpers
Browse files Browse the repository at this point in the history
Feature: Remove non standard helpers
  • Loading branch information
petermanser committed Apr 28, 2015
2 parents 035c3ef + acd02ba commit 640b67b
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 225 deletions.
2 changes: 0 additions & 2 deletions DependencyInjection/SmartiveHandlebarsExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ public function load(array $configs, ContainerBuilder $container)
$config = $this->processConfiguration($configuration, $configs);
$loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));

$loader->load('helpers.xml');

foreach ($config as $serviceName => $serviceConfig) {
if ($this->isConfigEnabled($container, $serviceConfig)) {
$this->loadService($serviceName, $serviceConfig, $container, $loader);
Expand Down
44 changes: 0 additions & 44 deletions Helper/AbstractHelper.php

This file was deleted.

64 changes: 0 additions & 64 deletions Helper/CompareHelper.php

This file was deleted.

52 changes: 0 additions & 52 deletions Helper/IsHelper.php

This file was deleted.

46 changes: 0 additions & 46 deletions Helper/WithHashHelper.php

This file was deleted.

24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Require the `smartive/handlebars-bundle` package in your composer.json and updat

Register the bundle and in `app/AppKernel.php`:

``` php
```php
// app/AppKernel.php
public function registerBundles()
{
Expand Down Expand Up @@ -86,3 +86,25 @@ The `smartive_handlebars.templating.renderer` service offers a `render($template

### Twig
To render Handlebars templates in Twig you can use the Twig function `handlebars(templateName, data)`.

## Custom Handlebars helpers
You can add you own Handlebars helpers as tagged services by extending from `Handlebars\Helper`. To find out more about how to write custom helpers please have a look at the [built-in helpers by xamin/handlebars.php](https://github.com/XaminProject/handlebars.php/tree/master/src/Handlebars/Helper).

Once you've implemented your own helper you have to register it as a service using the `smartive_handlebars.helper` tag and an appropriate alias:

```
# app/config/services.yml
services:
demo_bundle.my_demo_helper:
class: DemoBundle\Helpers\MyDemoHelper
tags:
- { name: smartive_handlebars.helper, alias: myDemo }
```

You now can use your custom Handlebars helper inside your templates as follows:

```handlebars
{{#myDemo parameter}}
{{!-- do stuff --}}
{{/myDemo}}
```
16 changes: 0 additions & 16 deletions Resources/config/helpers.xml

This file was deleted.

0 comments on commit 640b67b

Please sign in to comment.