{"id":33203246,"url":"https://github.com/ProAI/laravel-handlebars","last_synced_at":"2025-11-17T03:01:00.689Z","repository":{"id":31497541,"uuid":"35061775","full_name":"ProAI/laravel-handlebars","owner":"ProAI","description":":bicyclist: Laravel wrapper of LightnCandy for using Handlebars (and Mustache) templates","archived":false,"fork":false,"pushed_at":"2024-11-12T14:35:42.000Z","size":78,"stargazers_count":38,"open_issues_count":8,"forks_count":17,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-10-03T21:32:58.048Z","etag":null,"topics":["handlebars","laravel","lightncandy","mustache","php"],"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/ProAI.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-05-04T21:51:46.000Z","updated_at":"2024-11-13T00:25:25.000Z","dependencies_parsed_at":"2024-06-18T18:43:49.878Z","dependency_job_id":"03c85490-f714-4ed0-92cb-c95061088438","html_url":"https://github.com/ProAI/laravel-handlebars","commit_stats":{"total_commits":72,"total_committers":13,"mean_commits":5.538461538461538,"dds":0.625,"last_synced_commit":"b56b61d35f3e8fa9b02560f6761c0227b1baa63e"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/ProAI/laravel-handlebars","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProAI%2Flaravel-handlebars","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProAI%2Flaravel-handlebars/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProAI%2Flaravel-handlebars/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProAI%2Flaravel-handlebars/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ProAI","download_url":"https://codeload.github.com/ProAI/laravel-handlebars/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ProAI%2Flaravel-handlebars/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":284813088,"owners_count":27067232,"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","status":"online","status_checked_at":"2025-11-17T02:00:06.431Z","response_time":55,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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","laravel","lightncandy","mustache","php"],"created_at":"2025-11-16T09:00:32.856Z","updated_at":"2025-11-17T03:01:00.682Z","avatar_url":"https://github.com/ProAI.png","language":"PHP","readme":"# Laravel Handlebars\n\n[![Latest Stable Version](https://poser.pugx.org/proai/laravel-handlebars/v/stable)](https://packagist.org/packages/proai/laravel-handlebars) [![Total Downloads](https://poser.pugx.org/proai/laravel-handlebars/downloads)](https://packagist.org/packages/proai/laravel-handlebars) [![Latest Unstable Version](https://poser.pugx.org/proai/laravel-handlebars/v/unstable)](https://packagist.org/packages/proai/laravel-handlebars) [![License](https://poser.pugx.org/proai/laravel-handlebars/license)](https://packagist.org/packages/proai/laravel-handlebars)\n\nThis package allows you to use Handlebars (and Mustache) templates with Laravel. You can integrate Handlebars templates into Blade templates and you can even use the Blade language directives `@lang` and `@choice` in Handlebars templates.\n\nIt's the perfect choice, if you want to use the same templates in different languages (i. e. PHP and JavaScript) and/or server- and clientside. The compiling and rendering is veeery fast, because this package wraps the super fast template engine [LightnCandy](https://github.com/zordius/lightncandy).\n\n## Installation\n\nLaravel Handlebars is distributed as a composer package. So you first have to add the package to your `composer.json` file:\n\n- For Laravel 6+:\n\n    ```json\n    \"proai/laravel-handlebars\": \"^1.14\"\n    ```\n\n- For Laravel 5.5 to 5.8:\n\n    ```json\n    \"proai/laravel-handlebars\": \"~1.8\"\n    ```\n\n- For Laravel 5.1 to 5.4:\n\n    ```json\n    \"proai/laravel-handlebars\": \"~1.5.0\"\n    ```\n\nThen you have to run `composer update` to install the package. Once this is completed, you have to add the service provider to the providers array in `config/app.php`:\n\n```php\n/*\n * Package Service Providers...\n */\nProAI\\Handlebars\\HandlebarsServiceProvider::class,\n```\n\nYou can publish the package configuration with the following command:\n\n```console\nphp artisan vendor:publish --tag=laravel-handlebars\n```\n\n## Usage\n\n### Configuration\n\nMost of the options in `config/handlebars.php` are also used by [LightnCandy](https://github.com/zordius/lightncandy). So please have a look at the LightnCandy readme for more information.\n\nOnly the basedir option can't be set in this config file. Instead the package uses the `paths` option in `config/view.php` to define base directories and also the `compiled` option in the same file to define the directory for the compiled templates (i. e. the cache directory).\n\nIn addition to the LightnCandy options there are the options `language_helpers`, `optional_raw_output` and `translate_raw_output`. These options are described below.\n\n### Basics\n\nYou can use Handlebars templates the same way you use Blade templates. You can return them with `View::make('articles', ['name' =\u003e 'Taylor'])` or include them with the Blade `@include` directive, i. e. `@include('articles', ['name' =\u003e 'Taylor'])`.\n\nBy default all views which have a `.hbs` or `.handlebars` file extension are automatically detected as Handlebars templates. You can add more file extensions that should be treated as Handlebars templates in the `fileext` array in `config/handlebars.php`.\n\n### Language Helpers\n\nIf you wish, you can use the Blade language directives `@lang` and `@choice` in Handlebars templates, too. You have to set `$language_helpers = true` in order to use them. Here is an example:\n\n```php\n// Blade syntax:\n@lang('message', ['firstname' =\u003e 'John', 'lastname' =\u003e $lastname])\n@choice('comment_count', 2, ['item' =\u003e 'Article'])\n```\n```handlebars\n// Handlebars syntax:\n{{lang 'message' firstname='John' lastname=lastname }}\n{{choice 'comment_count' 2 item='Article' }}\n```\n\n### Raw Output\n\n_This feature is currently broken. If you want to use it, use v1.1 or below or [help to fix it](https://github.com/ProAI/laravel-handlebars/issues/12)!_\n\nIf you want to output the raw code of a template (maybe because you want to use the unrendered template clientside), you can set `$optional_raw_output = true` in the configuration. Then you can pass a variable `$raw = true` to the template or more comfortable you can use the `@raw` Blade directive.\n\n```php\n// Passing the $raw variable to the view:\nView::make('articles', ['raw' =\u003e true])\n@include('articles', ['raw' =\u003e true])\n```\n```php\n// Blade @raw directive:\n@raw('articles')\n```\n\nIf you want to output a raw template with compiled and rendered language variables, you can set `$translate_raw_output = true`.\n\n### Partials\n\nThis package automatically adds the directory of the current template to the basedir of LightnCandy. By that it is possible to easily include other Handlebars templates in the same directory. Just write `{{\u003e comment}}` to include `comment.hbs` from the same directory.\n\n### Example Template\n\n```handlebars\n{{#each array_variable }}\n\t{{#if this }}\n\t\t{{ output_some_variable }} {{\u003e include_templatename }}\n\t{{else}}\n\t\t{{lang 'language_variable' }}\n\t{{/if}}\n{{/each}}\n```\n\nFor more information about the Handlebars syntax see the [Handlebars documentation](http://handlebarsjs.com). It does not matter that the examples are for JavaScript, because Handlebars templates are the same for JavaScript and PHP.\n\n## Using it with Webpack\n\nIf you want to use this package client side with webpack, have a look at this article:\n\n[Sharing templates between PHP and JavaScript in Laravel](https://medium.com/@greut/sharing-templates-between-php-and-javascript-in-laravel-a5e07b43be24)\n\n## Support\n\nBugs and feature requests are tracked on [GitHub](https://github.com/proai/laravel-handlebars/issues).\n\n## License\n\nThis package is released under the [MIT License](LICENSE).\n","funding_links":[],"categories":["Packages"],"sub_categories":["Helpers/General"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FProAI%2Flaravel-handlebars","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FProAI%2Flaravel-handlebars","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FProAI%2Flaravel-handlebars/lists"}