All Projects → playframework → Twirl

playframework / Twirl

Licence: apache-2.0
Twirl is Play's default template engine

Programming Languages

scala
5932 projects

Projects that are alternatives of or similar to Twirl

Tuxedo
Tuxedo is a template language for Swift.
Stars: ✭ 80 (-83.94%)
Mutual labels:  template-engine, template-language
Play Slick
Slick Plugin for Play
Stars: ✭ 792 (+59.04%)
Mutual labels:  sbt-plugin, playframework
Phptal
PHP Template Attribute Language — template engine for XSS-proof well-formed XHTML and HTML5 pages
Stars: ✭ 155 (-68.88%)
Mutual labels:  template-engine, template-language
Pongo2
Django-syntax like template-engine for Go
Stars: ✭ 2,111 (+323.9%)
Mutual labels:  template-engine, template-language
gender-render
Template-system and proof-of-concept for rendering gender-neutral text-, email- and RPG-text-templates with the correct pronouns of all people involved.
Stars: ✭ 21 (-95.78%)
Mutual labels:  template-engine, template-language
Awesome Twig
A curated list of amazingly awesome Twig extensions, snippets and tutorials
Stars: ✭ 63 (-87.35%)
Mutual labels:  template-engine, template-language
Hepek
Web content generators in Scala. Intuitive, scalable, powerful.
Stars: ✭ 69 (-86.14%)
Mutual labels:  playframework, template-engine
Bars
Bars is a lightweight high performance HTML aware templating engine. Bars emits DOM rather than DOM-strings, this means the DOM state is preserved even if data updates happen.
Stars: ✭ 5 (-99%)
Mutual labels:  template-engine, template-language
escapevelocity
A subset reimplementation of Apache Velocity with a much simpler API.
Stars: ✭ 28 (-94.38%)
Mutual labels:  template-engine, template-language
sbt-sass
A fork of the sbt-sass repository which seems to be abandoned.
Stars: ✭ 32 (-93.57%)
Mutual labels:  sbt-plugin, playframework
Sbt Play Gulp
Gulp asset pipeline for Play Framework
Stars: ✭ 38 (-92.37%)
Mutual labels:  sbt-plugin, playframework
karkas
A tiny template engine based on TypeScript
Stars: ✭ 14 (-97.19%)
Mutual labels:  template-engine, template-language
sbt-play-npm
Integrate a Npm application with Play framework
Stars: ✭ 10 (-97.99%)
Mutual labels:  sbt-plugin, playframework
bart
A compile time templating language for Rust inspired by Mustache
Stars: ✭ 29 (-94.18%)
Mutual labels:  template-engine, template-language
Atmosphere
Realtime Client Server Framework for the JVM, supporting WebSockets with Cross-Browser Fallbacks
Stars: ✭ 3,552 (+613.25%)
Mutual labels:  playframework
Microwebsrv
A micro HTTP Web server that supports WebSockets, html/python language templating and routing handlers, for MicroPython (used on Pycom modules & ESP32)
Stars: ✭ 420 (-15.66%)
Mutual labels:  template-engine
Jetbrick Template 2x
Template Engine for Java
Stars: ✭ 351 (-29.52%)
Mutual labels:  template-engine
Thymeleaf Spring
Thymeleaf integration module for Spring
Stars: ✭ 349 (-29.92%)
Mutual labels:  template-engine
Ego
An ERB-style templating language for Go.
Stars: ✭ 477 (-4.22%)
Mutual labels:  template-language
Play Reactivemongo
🍃 ReactiveMongo plugin for Playframework
Stars: ✭ 411 (-17.47%)
Mutual labels:  playframework

Twirl Latest version Build Status

Twirl is the Play template engine.

Twirl is automatically available in Play projects and can also be used stand-alone without any dependency on Play.

See the Play documentation for the template engine for more information about the template syntax.

sbt-twirl

Twirl can also be used outside of Play. An sbt plugin is provided for easy integration with Scala or Java projects.

sbt-twirl requires sbt 1.3.0 or higher.

To add the sbt plugin to your project add the sbt plugin dependency in project/plugins.sbt:

addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % "LATEST_VERSION")

Replacing the LATEST_VERSION with the latest version published, which should be Latest version. And enable the plugin on projects using:

someProject.enablePlugins(SbtTwirl)

If you only have a single project and are using a build.sbt file, create a root project and enable the twirl plugin like this:

lazy val root = (project in file(".")).enablePlugins(SbtTwirl)

Template files

Twirl template files are expected to be placed under src/main/twirl or src/test/twirl, similar to scala or java sources. The source locations for template files can be configured.

Template files must be named {name}.scala.{ext} where ext can be html, js, xml, or txt.

The Twirl template compiler is automatically added as a source generator for both the main/compile and test configurations. When you run compile or test:compile the Twirl compiler will generate Scala source files from the templates and then these Scala sources will be compiled along with the rest of your project.

Additional imports

To add additional imports for the Scala code in template files, use the templateImports key. For example:

TwirlKeys.templateImports += "org.example._"

Source directories

To configure the source directories where template files will be found, use the sourceDirectories in compileTemplates key. For example, to have template sources alongside Scala or Java source files:

sourceDirectories in (Compile, TwirlKeys.compileTemplates) := (unmanagedSourceDirectories in Compile).value

Credits

The name twirl was thought up by the Spray team and refers to the magic @ character in the template language, which is sometimes called "twirl".

The first stand-alone version of Twirl was created by the Spray team.

An optimized version of the Twirl parser was contributed by the Scala IDE team.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].