Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sfxcode/pebble-scala

A wrapper library for using [Pebble Templates](https://pebbletemplates.io/) in Scala.
https://github.com/sfxcode/pebble-scala

pebble pebble-templates scala template-engine templating

Last synced: 18 days ago
JSON representation

A wrapper library for using [Pebble Templates](https://pebbletemplates.io/) in Scala.

Awesome Lists containing this project

README

        

# pebble-scala

A wrapper library for using [Pebble Templates](https://pebbletemplates.io/) in Scala.

Adds first class scala support to Pebble.

## Features

* 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
* ...

## Version
Scala Version is 2.13.x / 3.0.0

## SBT

```
libraryDependencies += "com.sfxcode.templating" %% "pebble-scala" % "1.0.2"
```

## Travis

[![Build Status](https://travis-ci.org/sfxcode/pebble-scala.svg?branch=master)](https://travis-ci.org/sfxcode/pebble-scala)

## Download

[ ![Download](https://api.bintray.com/packages/sfxcode/maven/pebble-scala/images/download.svg) ](https://bintray.com/sfxcode/maven/pebble-scala/_latestVersion)

## Usage

1. Write Template

```html

{{ info.name }}


    {% for value in list %}
  • {{ value }}

  • {% endfor %}

```

2. Init Engine

Scala map with global engine parameter is optional ...

```scala
val Engine: ScalaPebbleEngine = ScalaPebbleEngine(globalContext = Map("header" -> "pebble-scala"))
```

3. Evaluate

```
val context = Map("list" -> List("Resolver for Scala values", "iterate over scala collections"))
val evaluated = Engine.evaluateToString("templates/template.peb", context)
```

4. Result

```html

pebble-scala


  • Resolver for Scala values

  • iterate over scala collections

```

## Supporters

JetBrains is supporting this open source project with:

[![Intellij IDEA](http://www.jetbrains.com/img/logos/logo_intellij_idea.png)](http://www.jetbrains.com/idea/)