Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Amadeus82/sbt-handlebars
This is an sbt-web plugin for using handlebar templates in Play in a very simple way
https://github.com/Amadeus82/sbt-handlebars
Last synced: 2 months ago
JSON representation
This is an sbt-web plugin for using handlebar templates in Play in a very simple way
- Host: GitHub
- URL: https://github.com/Amadeus82/sbt-handlebars
- Owner: Amadeus82
- Created: 2014-07-27T20:22:38.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2018-08-24T17:12:19.000Z (over 6 years ago)
- Last Synced: 2024-08-03T06:02:04.775Z (6 months ago)
- Language: Scala
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-sbt-plugins - sbt-handlebars
README
sbt-handlebars
==============This is an sbt-web plugin enabling client side html rendering using the handlebar libraray in Play >=2.3.x.
## How to install
Add a resover in project/plugin.sbt
```scala
resolvers ++= Seq(
Resolver.url("Dataflow repository", url("https://amadeus82.github.io/repo"))(Resolver.ivyStylePatterns)
)
```Add a plugin dependency in project/plugin.sbt
```scala
addSbtPlugin("com.dataflow.sbt" % "sbt-handlebars" % "1.0.0")
```Add a library dependency in build.sbt for the external handlebars web-jar
```scala
libraryDependencies ++= Seq(
"org.webjars" % "handlebars" % "2.0.0-alpha.2"
)
```Add the handleburs plugin to the list of sourceGenerators in build.sbt
```scala
sourceGenerators in Assets <+= handlebars
```Reference two javascript files in your view where ever needed (i.e. main.scala.html)
```javascript```
Please be aware that the order of those two lines matter as the javascript file (templates.js) generated
by this plugin extends the Handlebar object by a new member Templates.## Usage:
If you have a handlebars template at
**app/assets/handlebars/filter/standard.html**
This template will be available as a javascript object **Handlebars.Templates.Filter.Standard**## Example:
In order to render a file:
**app/assets/handlebars/filter/standard.html**
having the variable hint, description and items, you write the following javascript
code on the client side.```javascript
Handlebars.compile(Handlebars.Templates.Filter.Standard)({
hint: Messages('layout.filter.dialog.hint.caption'),
description: Messages('layout.filter.dialog.hint.description'),
items: items
});
```