Using Laravel's blade with Mustache or Handlebars
Create a new partial for the mustache or handlebars template without using the blade.php extension.:
<script id="friend-list-template" type="text/x-handlebars-template">
<p>
<ul id="ul-friends">
{{#each friends}}
<li>
<input type="checkbox" data-id="{{ id }}" data-name="{{ name }}">
{{ name }}
</li>
{{/each}}
</ul>
</p>
</script>
Then include it on the page where you originally included the handlebars / mustache template:
@include('partials.mustache_template')
Written by Wern Ancheta
Related protips
7 Responses
Thank you!
Thanks. But how do i use it with .blade.php extension.
Awesome!!!
I think the point is to include the partial template without the blade extension from a blade template.
if you need to use it witin the same main view, you can use @{{ }} to make blade ignore the brackets
if you need to use it witin the same main view, you can use @{{ }} to make blade ignore the brackets
I don't think there is any need for using Handlebar with Laravel blade, which itself is really easy to setup. You can easily create layout in Laravel by creating include files and then calling it from your view file.