Last Updated: September 27, 2021
·
18.6K
· wern

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') 

7 Responses
Add your response

Thank you!

over 1 year ago ·

Thanks. But how do i use it with .blade.php extension.

over 1 year ago ·

Awesome!!!

over 1 year ago ·

I think the point is to include the partial template without the blade extension from a blade template.

over 1 year ago ·

if you need to use it witin the same main view, you can use @{{ }} to make blade ignore the brackets

over 1 year ago ·

if you need to use it witin the same main view, you can use @{{ }} to make blade ignore the brackets

over 1 year ago ·

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.

over 1 year ago ·