LearnFast.Ninja

Mustache master page template

How to create a master page template in mustache.

master.html

<!DOCTYPE html>

<html>

<head>

      {{>head}}

</head>
<
body>
      <header>

            <a href="/">website name</a>

      </header>

      <div>
            {{>content}}
     
</div>

      {{>footer}}

</body>

</html>


head.html

<title>{{head.title}}</title>

<link rel="shortcut icon" href="favicon.ico" />


content.html

{{#homepage}}

    {{> homepage}}

{{/homepage}}


{{#post}}
    {{> post}}

{{/post}}


footer.html

<footer>
      Privacy Policy | Terms of Service
</footer>


Data example:

.render('master', {

    head: {

      title: 'Title'

    },

    homepage: {
      items: items
    }

}


Tags

mustache

master-page template