{"id":22542476,"url":"https://github.com/brightmachine/laratash","last_synced_at":"2025-10-25T08:37:29.479Z","repository":{"id":20971220,"uuid":"24260130","full_name":"brightmachine/laratash","owner":"brightmachine","description":"A Laravel wrapper for mustache.php, a PHP implementation of http://mustache.github.io/","archived":false,"fork":false,"pushed_at":"2017-12-12T11:23:42.000Z","size":17,"stargazers_count":12,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-16T12:44:37.920Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/brightmachine.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2014-09-20T10:32:09.000Z","updated_at":"2019-03-11T09:02:02.000Z","dependencies_parsed_at":"2022-07-30T02:48:03.205Z","dependency_job_id":null,"html_url":"https://github.com/brightmachine/laratash","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/brightmachine/laratash","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightmachine%2Flaratash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightmachine%2Flaratash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightmachine%2Flaratash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightmachine%2Flaratash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/brightmachine","download_url":"https://codeload.github.com/brightmachine/laratash/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/brightmachine%2Flaratash/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278671729,"owners_count":26025743,"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-10-06T02:00:05.630Z","response_time":65,"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":[],"created_at":"2024-12-07T13:10:33.243Z","updated_at":"2025-10-06T19:48:18.930Z","avatar_url":"https://github.com/brightmachine.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"laratash\n========\n\nA Laravel wrapper for mustache.php, a PHP implementation of http://mustache.github.io/\n\n# Acknowledgements\n\nThis project is based entirely on the the [mustache-l4](https://github.com/conarwelsh/mustache-l4) package\nby Conar Welsh and contributors.\n\n## Supports\n- `Laravel 5`\n- `mustache/mustache 2.7+`\n\n# Installation\n\nAdd laratash as a dependency to your `composer.json` file:\n\n```json\n\"require\": {\n\t\"laravel/framework\":      \"~5.0\",\n\t\"brightmachine/laratash\": \"~5.0\"\n}\n```\n\nrun `composer update`, or `composer install` if this is a brand new project\n\t\n## Add the Service Provider\n\nOpen: `config/app.php`\n\n```php\n...\n\n'Laratash\\LaratashServiceProvider',\n\t\n...\n```\n\nYou are all setup!\n\n\n# Usage\n\nLaratash is merely a wrapper for the [Mustache.php](https://github.com/bobthecow/mustache.php) library that integrates it into Laravel 5+.\n\nLaratash registers itself with the Laravel View class, providing seamless integration with Laravel.  You can use Mustache just as you would Blade!\nThe Laravel View class will choose the right template engine to use based on the file extension of the view.  So all you have to do to render Mustache files, is ensure that your view has a `.mustache` file extension.  Laratash will take care of the rest.\n\nYou can even mix and match template engines.  For instance maybe you have a Blade layout file, and you want to nest a Mustache view, that's fine!  However just be aware of the fact that Mustache does not understand Block Sections like Blade does.\nThe Mustache view will be rendered into a variable named whatever section you passed the view to.  So for example if you were to do:\n\n```php\n$view-\u003enest('content', 'some.view');\n$view-\u003enest('sidebar', 'some.sidebar');\n```\n\nThe contents of the parsed `some.view` file will be available in the template file under a variable called `$content`.\nThe contents of the parsed `some.sidebar` would be available in the template file, under a variable called `$sidebar`.\n\nBy default, Mustache partials are also loaded using Laravel's ViewFinder, so you can feel free to use dot-notation to specify a view.\n\n```html\n{{#posts}}\n\t{{\u003e posts._post}}\n{{/posts}}\n```\n\nOther than that it is business as usual!\n\n# Examples:\n\n- Example using View::make()\n\n\tapp/views/test.mustache\n\t\n\t\t\u003ch1\u003e{{ pageHeading }}\u003c/h1\u003e\n\t\t\u003cdiv\u003e\n\t\t\t{{ pageContent }}\n\t\t\u003c/div\u003e\n\t\t\n\tapp/router.php\n\t\n\t\tRoute::get('/', function()\n\t\t{\n\t\t\treturn View::make('test', array(\n\t\t\t\t'pageHeading' =\u003e 'Rendered with Mustache.php',\n\t\t\t\t'pageContent' =\u003e 'But still looks like Laravel!'\n\t\t\t));\n\t\t});\n\n- Example using a Blade controller layout\n\t\n\tapp/views/layouts/master.blade.php\n\n\t\t\u003chtml\u003e\n\t\t\u003chead\u003e\u003c/head\u003e\n\t\t\u003cbody\u003e\n\t\t\t{{-- since Mustache does not use sections, the nested section will instead\n\t\t\tbe rendered as a variable --}}\n\t\t\t{{ content }}\n\t\t\u003c/body\u003e\n\t\t\u003c/html\u003e\n\t\t\n\tapp/views/test.mustache\n\t\n\t\t\u003ch1\u003e{{ pageHeading }}\u003c/h1\u003e\n\t\t\u003cdiv\u003e\n\t\t\t{{ pageContent }}\n\t\t\u003c/div\u003e\n\t\n\tapp/controllers/TestController.php\n\n\t\t\u003c?php\n\n\t\tclass TestController extends BaseController {\n\t\t\n\t\t    public $layout = 'layouts.master';\n\t\t    \n\t\t    public function index()\n\t\t    {\n\t\t \t$this-\u003elayout-\u003enest('content', 'test', array(\n\t\t \t\t'pageHeading' =\u003e 'Rendered with Mustache.php',\n\t\t\t\t'pageContent' =\u003e 'But still looks like Laravel!'\n\t\t \t));   \n\t\t    }\n\t\t    \n\t    \t}\n\t    \t\n- Example using a Mustache layout\n\n\tapp/views/posts/_post.mustache\n\t\t\n\t\t\u003carticle\u003e\n\t\t\t\u003ch2\u003e{{ title }}\u003c/h2\u003e\n\t\t\t\u003cdiv\u003e\n\t\t\t\t{{ content }}\n\t\t\t\u003c/div\u003e\n\t\t\u003c/article\u003e\n\t\n\tapp/views/blog/index.mustache\n\n\t\t\u003chtml\u003e\n\t\t\u003chead\u003e\u003c/head\u003e\n\t\t\u003cbody\u003e\n\t\t\t\u003ch1\u003eMy Blog\u003c/h1\u003e\n\t\t\t\n\t\t\t{{#posts}}\n\t\t\t\t{{\u003e posts._post}}\n\t\t\t{{/posts}}\n\t\t\u003c/body\u003e\n\t\t\u003c/html\u003e\n\t\t\n\tapp/routes.php\n\t\n\t\tRoute::get('/', function()\n\t\t{\n\t\t\t$posts = array(\n\t\t\t\tarray(\n\t\t\t\t\t'title' =\u003e 'This is a Title',\n\t\t\t\t\t'content' =\u003e 'lorem ipsum...'\n\t\t\t\t),\n\t\t\t\tarray(\n\t\t\t\t\t'title' =\u003e 'This is a another title',\n\t\t\t\t\t'content' =\u003e 'lorem ipsum...'\n\t\t\t\t),\n\t\t\t\tarray(\n\t\t\t\t\t'title' =\u003e 'This is yet another Title',\n\t\t\t\t\t'content' =\u003e 'lorem ipsum...'\n\t\t\t\t),\n\t\t\t);\n\t\t\t\n\t\t\treturn View::make('blog.index', compact('posts));\n\t\t});\n\n## A note on template data\n\nLaravel expects [view data](http://laravel.com/docs/5.0/views#basic-usage) to be be passed as an `array`.\n\nMustache PHP, however, also allows a Context object to be used.\n\nIf you wish to use a Context object, pass through an array with a `__context` key and this will be used. E.g.\n\n    `return view('my.view', ['__context' =\u003e new Context]);`\n\n# Configure\n\nYou can alter the configuration options that are passed to Mustache.php in your `ConfigServiceProvider`. E.g. \n\n\tconfig([\n\t\t'laratash.cache' =\u003e storage_path() . '/framework/views/mustache',\n\t]);\n\t\nAll `laratash.` options are passed directly to the Mustache_Engine constructor, so you can use any of the options that you would use with [Mustache.php](https://github.com/bobthecow/mustache.php)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrightmachine%2Flaratash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbrightmachine%2Flaratash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbrightmachine%2Flaratash/lists"}