Open Source Docs

Avocet

Fast HTML template engine and eDSL for Scala 3

Static Rendering

Static HTML rendering with Avocet core


Static rendering

You can use Avocet as a static HTML renderer.

// build.sbt
libraryDependencies += "com.natural-transformation" %% "avocet-core" % "1.0.0"
// In your code
import avocet.text.renderHtml
import avocet.dsl._
import html._

val features = Seq("Very fast", "Memory-effective")

val html = renderHtml {
  optimize {
    body(
      div(
        clazz := "title",
        backgroundColor @= "red",
        "Hello, I'm Avocet!"
      ),
      ul(clazz := "list",
        features map { feature =>
          li(class := "item", feature)
        }
      )
    )
  }
}

println(html)
<body>
  <div style="background-color: red" class="title">Hello, I'm Avocet!</div>
  <ul class="list">
    <li class="item">Very fast</li>
    <li class="item">Memory-effective</li>
  </ul>
</body>

Benchmarks

The benchmark table is available in the README: