Skip to content
DreadLocks is the new template engine for Scala programmers
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

Welcome to DreadLocks

The DreadLocks is new template engine for Scala programmers, and supported scala syntax in your template files.

Getting Started

  1. Install DreadLocks

Download latest dreadlocks.jar from GitHub:


  • Support Scala expression

    Currently support limited Scala expression, foreach, if-elseif-else, to apply method and more.


  • fast

    The DreadLocks aims to be fastest template engine.

  • easy to use

    Support all Scala expression.


DreadLocks used simple-build-tool project to build source and manage it. You can build after installed and setuped simple-build-tools. The simple-build-tool project are hosted on Google Code

% sbt compile % sbt package

For more details, please see simple-build-tool documentation.


  • Optimize and Speed up!!
  • Nested tamplates
  • Caching
  • More support of expression of Scala
  • Better error message


You should to import DreadLocks code at the top on your program.

import org.scalalites.dreadlocks._

The DreadLocks temlate engine allows ${...} and #{...} syntax to evaluate the variable, and

syntax is evaluated as statements, like foreach, if-else etc. You can see some

examples below. There are many exmaples in src/test/resources/ and src/test/scala/, please see them.

template_variable.shtml: <title>${title}</title> #{body}

TemplateVariable.scala: // You can specify instance of, or String to constructor of Template class. val input = Source.fromFile("template_variable.shtml").getLines.mkString val template = Template(input) val context = Context("title" -> "Welcome to DreadLocks", "body" -> "DreadLocks project are hosted on") val output = template.render(context)

// <html>
//    <head>
//        <title>Welcome to DreadLocks</title>
//    </head>
//    <body>DreadLocks project are hosted on</body>
// </html>

ex. Examples that evaluate iterable variables and if-else statement.

hamburgers.txt Delicious hamburger restraunts in Japan: ?> * ${restraunt}

Side menus:
<?sc if(haveSideMenu) { ?>
    * ${sideMenus("potato")}
    * ${sideMenus("coleslaw")}
<?sc } ?>

Complex.scala // You can specify instance of, or String to constructor of Template class. val source = Source.fromFile("template_variable.shtml") val template = Template(source) val context = Context("restraunts" -> List("Baker Bounce", "Great Burger", "FELLOWS"), "haveSideMenu" -> true, "sideMenus" -> HashMap("potato" -> "French fries", "coleslaw" -> "Coleslaw"))

val output = template.render(context)
// Console.println(output)
// Delicious hamburger restraunts in Japan:
//   * Baker Bounce
//   * Great Burger
//   * FELLOWS
// Side menus:
//   * French fries
//   * Coleslaw
You can’t perform that action at this time.