Clipped moustache. Include header and footer in a Mustache template

A template for creating web pages is great if you want to integrate front- and backend easy. I have been using Mustache for a while and I'm quite satisfied. It works great with both Dropwizard and Spark Mustache for.

The documentation says how to include a snippet from another template. But searching for it was not that easy.

The problem I would like to solve is to reuse the same header and footer on many web pages. That is, include a snippet from another template into a template.

The solution is to refer to a another template from a template using

<!DOCTYPE HTML> <html> <head> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"> </head> <body>

How to grow big mustache

<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> </body> </html>

The result is a web page like this:

<!DOCTYPE HTML> <html> <head> <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet"> </head> <body> <p>Page content</p> <script src="http://code.jquery.com/jquery-1.11.3.min.js"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script> </body> </html>

This solves my problem with the same header and footer on each page using Mustache. Using the template system is different if you use Dropwizard, Spark or any other tool. But that is out of scope today.

Narrow mustache

Acknowledgements

I would like to thank Malin Ekholm and Johan Helmfrid for proof reading.

Resources

Dropwizard - a Java framework for developing ops-friendly, high-performance, RESTful web services

Spark - a tiny Sinatra inspired framework for creating web applications in Java 8 with minimal effort

mustache-styles.com

Posted by at 03:57PM

Tags: clipped moustache, moustache trimming tips, how to keep your mustache neat, mustache and chin hair, beard styles no moustache, mustache or goatee, how to draw a moustache on your face, how to grow big mustache, latest moustache trends, narrow mustache

Overall rating page: 4.5/5 left 18590 people.

Comments

There are no comments for this post "Include header and footer in a Mustache template". Be the first to comment...

Add Comment