Package

lol

html

Permalink

package html

HTML templating.

val items: List[Item] = ???
val content: Html = tmpl"""
  <­h1>Items<­/h1>
  @if(items.isEmpty) {
    <­em>No results<­/em>
  }
  else {
    <­ul>
       @items.map { item =>
         <li>@item.name</li>
       }

  }
"""

Html values can also be easily created from the html interpolation. Conversion from Scala values is done via the ToHtml type class.

val content: Html = html"""Hello $${name}!"""

They will be encoded as lol.http.Content thanks to Html.encoder.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. html
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Type Members

  1. case class Html(content: String) extends Product with Serializable

    Permalink

    An HTML document.

  2. implicit class HtmlInterpolation extends AnyRef

    Permalink

    The html interpolation allows to create Html values from plain string.

  3. implicit class SeqHtmlExtensions extends AnyRef

    Permalink

    Extension methods for Seq[Html].

  4. implicit class SeqHtmlExtensions0[A] extends AnyRef

    Permalink

    Extension methods for Seq[_].

  5. implicit class TemplateInterpolation extends AnyRef

    Permalink

    The tmpl interpolation allows to create Html values from a string template.

    The tmpl interpolation allows to create Html values from a string template.

    The template syntax is almost the same as Twirl (https://www.playframework.com/documentation/2.6.x/ScalaTemplates). It is often more convenient that using imbricated string interpolation.

  6. trait ToHtml[-A] extends AnyRef

    Permalink

    A type class to provide Html rendering.

Value Members

  1. object Html extends Serializable

    Permalink

    Provides the ContentEncoder for HTML documents.

  2. object ToHtml

    Permalink

    Default instances for the ToHtml type class.

  3. implicit def toHtml[A](value: A)(implicit arg0: ToHtml[A]): Html

    Permalink

    Convert a value to Html using the right ToHtml type class instance.

    Convert a value to Html using the right ToHtml type class instance.

    If using the provided type class instances, values are encoded this way.:

    • String values are safely HTML escaped to avoid XSS issues with generated documents.
    • scala.Option can be directly inserted. Some values content is included, while
    • None produces an empty string.
    • scala.Unit produces an empty string.
    • scala.Seq outputs every item without any separator.

Inherited from AnyRef

Inherited from Any

Ungrouped