Beard is an open-source, logic-less templating engine, written in Scala and inspired by Mustache. You can use it out-of-the-box; see the Requirements list below.
What makes Beard powerful:
- Streaming. As soon as you need to render something, you can stream it to the browser. This provides high user-perceived performance.
- Speed. We've benchmarked it against other template engines for the JVM, and Beard performed much faster in terms of rendering time. (We invite you to run your own benchmarks to see if you get the same results.) It also uses ANTLR to make template compilation fast.
- It offers template inheritance.
- Its simple, beautiful syntax. A la Mustache, it uses only the
{
and}
markers for tags and delimiters.
Here's a code snippet to show you how simply Beard can parse templates:
<html>
<head>
<title>{{ the.title }}</title>
</head>
<body>
{{ the.content }}
</body>
</html>
- Scala 2.10 or 2.11
- a package manager like sbt or Maven
If you're using sbt, add this line to your build.sbt file:
libraryDependencies += "de.zalando" %% "beard" % "0.1.2"
resolvers ++= Seq(
"zalando-maven" at "https://dl.bintray.com/zalando/maven"
)
If you're using Maven, run this:
<dependency>
<groupId>de.zalando</groupId>
<artifactId>beard</artifactId>
<version>0.1.2</version>
</dependency>
Binaries are available from bintray
We've started a Gitbook for additional docs. There, you'll find more information on:
- Basic Usage: rendering an
index
template - Control Flow: If statements and For statements
- Template Inheritance: layout templates and templates-to-be-rendered
- Filters: describes the filters feature
- Quick Reference: with details and code on interpolation, comment statements, block statements, yield statements, and more
You can contribute to this documentation here.
##Contributing/TODO List
We gladly welcome contributions—just submit a pull request with a short note summarizing briefly (1-2 sentences) what you've done. If you'd like to make a substantial contribution to Beard, we could use your help with these items:
- adding filters: ind Handlebars, Angular, Twig, etc.
- providing more meaningful error messages
- XSS prevention; see related issue