Skip to content

SpinGo/handlebars-play-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

handlebars-play-json

Play-JSON data bindings for handlebars.scala

Installation:

libraryDependencies += "com.spingo" %% "handlebars-play-json" % "0.2.1"

Example:

Main.scala:

package fun

import com.gilt.handlebars.Handlebars
import com.spingo.handlebars.PlayJsonBinding._
import play.api.libs.json._

object Main extends App {
  val json = Json.parse("""
    {
      "lucky": [1,2,3,5,8],
      "name": { "first":  "Tim"},
      "favorites": {
        "color": "blue",
        "language": "scala"
      }
    }""")

  val template = """
My name is {{name.first}}.

These are my favorite #'s:
{{#lucky}}
- {{this}}{{/lucky}}

These are my favorite things:
{{#each favorites}}
- {{@key}}: {{this}}{{/each}}
"""
  val hb = Handlebars(template)

  println(hb(json))
}

About

Play-JSON data bindings for handlebars.scala

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages