A wrapper library for using Pebble Templates in Scala.
Adds first class scala support to Pebble.
- Resolver for Scala values
- Support Scala Lists, Set, Maps, Options, ...
- Loops support scala collections
- Scala Support for Tests (empty, map, iterable)
- iterate over scala collections
- implement do Tag
- ...
Scala Version is 2.13.x / 3.0.0
libraryDependencies += "com.sfxcode.templating" %% "pebble-scala" % "1.0.2" - Write Template
<html> <head> <title>{{ info.name }}</title> </head> <body> <ul> {% for value in list %} <li>{{ value }}</li> {% endfor %} </ul> </body> </html>- Init Engine
Scala map with global engine parameter is optional ...
val Engine: ScalaPebbleEngine = ScalaPebbleEngine(globalContext = Map("header" -> "pebble-scala"))- Evaluate
val context = Map("list" -> List("Resolver for Scala values", "iterate over scala collections")) val evaluated = Engine.evaluateToString("templates/template.peb", context) - Result
<html> <head> <title>pebble-scala</title> </head> <body> <ul> <li>Resolver for Scala values</li> <li>iterate over scala collections</li> </ul> </body> </html>JetBrains is supporting this open source project with:
