{"id":14983669,"url":"https://github.com/smartive/smartivehandlebarsbundle","last_synced_at":"2025-11-02T02:30:40.942Z","repository":{"id":29637124,"uuid":"33178383","full_name":"smartive/SmartiveHandlebarsBundle","owner":"smartive","description":"Bundle to integrate Handlebars templates into your Symfony2 / Symfony3 application","archived":true,"fork":false,"pushed_at":"2022-10-05T16:04:50.000Z","size":54,"stargazers_count":6,"open_issues_count":2,"forks_count":2,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-02-17T13:25:14.643Z","etag":null,"topics":["handlebars","handlebars-template","php","symfony","symfony2","symfony3","twig"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smartive.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-03-31T10:04:59.000Z","updated_at":"2024-10-29T07:45:25.000Z","dependencies_parsed_at":"2022-07-25T18:47:23.560Z","dependency_job_id":null,"html_url":"https://github.com/smartive/SmartiveHandlebarsBundle","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartive%2FSmartiveHandlebarsBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartive%2FSmartiveHandlebarsBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartive%2FSmartiveHandlebarsBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartive%2FSmartiveHandlebarsBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smartive","download_url":"https://codeload.github.com/smartive/SmartiveHandlebarsBundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239362417,"owners_count":19626129,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["handlebars","handlebars-template","php","symfony","symfony2","symfony3","twig"],"created_at":"2024-09-24T14:07:45.511Z","updated_at":"2025-11-02T02:30:40.906Z","avatar_url":"https://github.com/smartive.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/smartive/SmartiveHandlebarsBundle.svg?branch=master)](https://travis-ci.org/smartive/SmartiveHandlebarsBundle)\n[![Coverage Status](https://coveralls.io/repos/smartive/SmartiveHandlebarsBundle/badge.svg?branch=master\u0026service=github)](https://coveralls.io/github/smartive/SmartiveHandlebarsBundle?branch=master)\n[![Latest Stable Version](https://poser.pugx.org/smartive/handlebars-bundle/v/stable)](https://packagist.org/packages/smartive/handlebars-bundle)\n[![Total Downloads](https://poser.pugx.org/smartive/handlebars-bundle/downloads)](https://packagist.org/packages/smartive/handlebars-bundle)\n[![License](https://poser.pugx.org/smartive/handlebars-bundle/license)](https://packagist.org/packages/smartive/handlebars-bundle)\n\n# SmartiveHandlebarsBundle\n\nBundle to integrate Handlebars templates into your Symfony2 / Symfony3 application.\n\nThis bundle renders handlebars with the help of [xamin/handlebars.php](https://github.com/XaminProject/handlebars.php).\n\n## Installation\n\nRequire the `smartive/handlebars-bundle` package in your composer.json and update your dependencies.\n\n```\n{\n    …\n    \"require\": {\n        \"smartive/handlebars-bundle\": \"dev-master\"\n    }\n    …\n}\n```\n\nRegister the bundle in `app/AppKernel.php`:\n\n```php\n// app/AppKernel.php\npublic function registerBundles()\n{\n    return array(\n        // ...\n        new Smartive\\HandlebarsBundle\\SmartiveHandlebarsBundle(),\n    );\n}\n```\n\n## Configuration\n\nSome of the features can be configured in the ``smartive_handlebars`` section of `app/config/config.yml`.\n\n### Handlebars file extension\n\nThe default file extension for Handlebars files is set to `.hbs`. \nThis can be overridden using the following setting (example file extension set to `.handlebars`):\n\n```\nsmartive_handlebars:\n    templating:\n        file_extension: .handlebars\n```\n\n### Template directories\n\nThe `template_directories` setting lets you define where to look for Handlebars templates.\nYou can use Symfony resource notation as well as absolute file paths to configure directories.\n\n\n```\nsmartive_handlebars:\n    templating:\n        template_directories:\n            - '@AcmeDemo/Resources/views/Templates'\n            - /var/www/templates\n```\n\nBy default, templates are getting search for in template directories recursively.\nYou can disable this behaviour as follows:\n\n```\nsmartive_handlebars:\n    templating:\n        template_directories_recursive: false\n```\n\n### Twig extension\n\nThe Handlebars Twig extension is enabled by default. To disable it add this to your configuration:\n\n```\nsmartive_handlebars:\n    twig:\n        enabled: false\n```\n\n## Usage\n\n### Rendering service\nThe `smartive_handlebars.templating.renderer` service offers a `render($templateName, $data)` method which can be use to render Handlebars templates.\n\n### Twig\nTo render Handlebars templates in Twig you can use the Twig function `handlebars(templateName, data)`.\n\n## Custom Handlebars helpers\nYou can add you own Handlebars helpers as tagged services by implementing the `Handlebars\\Helper` interface. 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).\n\nOnce you've implemented your own helper you have to register it as a service using the `smartive_handlebars.helper` tag and an appropriate alias:\n\n```\n# app/config/services.yml\nservices:\n    demo_bundle.my_demo_helper:\n        class: DemoBundle\\Helpers\\MyDemoHelper\n        tags:\n            - { name: smartive_handlebars.helper, alias: myDemo }\n```\n\nYou now can use your custom Handlebars helper inside your templates as follows:\n\n```handlebars\n{{#myDemo parameter}}\n    {{!-- do stuff --}}\n{{/myDemo}}\n```\n\n## Caching\n\nThe rendering service offers the ability to cache the parsed template between requests for faster rendering.\n\nYou can enable caching by setting `smartive_handlebars.cache` to a existing cache service ID in your `app/config/config.yml`:\n\n```\nsmartive_handlebars:\n    cache:\n        enabled: true\n        service: \u003cservice-id\u003e\n```\n\nThere are several caching services / strategies available per default:\n\n### Disk\n\nService ID: `smartive_handlebars.cache.disk`\n\nUses [Handlebars\\Cache\\Disk](https://github.com/XaminProject/handlebars.php/blob/master/src/Handlebars/Cache/Disk.php) to read/write file cache in Symfony's cache directory\n\n### APC\n\nService ID: `smartive_handlebars.cache.apc`\n\nUses [Handlebars\\Cache\\APC](https://github.com/XaminProject/handlebars.php/blob/master/src/Handlebars/Cache/APC.php) to read/write cache objects using [APC](http://php.net/manual/en/book.apc.php)\n\n### Redis\n\nService ID: `smartive_handlebars.cache.redis`\n\nUses [PhpRedis](https://github.com/phpredis/phpredis) or [Predis](https://github.com/nrk/predis) to read/write cache objects using a [Redis Server](http://redis.io/). \nThis bundle integrates with [RedisBundle](https://github.com/snc/SncRedisBundle) in order to make configuring your Redis implementation even easier. \nThe default Redis client being used is `snc_redis.default` (see [RedisBundle documentation](https://github.com/snc/SncRedisBundle/blob/master/Resources/doc/index.md#usage)).\n\nThe default configuration can be overridden looks as follows:\n\n```\nsmartive_handlebars:\n    cache:\n        redis:\n            client_service: snc_redis.default\n            key_prefix: 'smartive-handlebars:'\n```\n\n### Custom\n\nYou can also define your own caching services by adding a class which implements [Handlebars\\Cache](https://github.com/XaminProject/handlebars.php/blob/master/src/Handlebars/Cache.php). \nTo use your custom cache service you have to register it in your service configuration:\n\n```\n# app/config/services.yml\nservices:\n    demo_bundle.my_demo_cache_service:\n        class: DemoBundle\\Cache\\CustomCache\n```\n\n```\n# app/config/config.yml\nsmartive_handlebars:\n    cache: demo_bundle.my_demo_cache_service\n```\n\n## Complete configuration example\n\n```\n# app/config/config.yml\nsmartive_handlebars:\n    templating:\n        enabled: true\n        file_extension: .hbs\n        template_directories:\n            - '@AcmeDemo/Resources/views/Templates'\n            - /var/www/templates\n        template_directories_recursive: true\n    twig:\n        enabled: true\n    cache:\n        enabled: false\n        service: smartive_handlebars.cache.redis\n        redis:\n            client_service: snc_redis.default\n            key_prefix: 'smartive-handlebars:'\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartive%2Fsmartivehandlebarsbundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmartive%2Fsmartivehandlebarsbundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartive%2Fsmartivehandlebarsbundle/lists"}