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.
- Source
- package.scala
- Alphabetic
- By Inheritance
- html
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
case class
Html(content: String) extends Product with Serializable
An HTML document.
-
implicit
class
HtmlInterpolation extends AnyRef
The
html
interpolation allows to create Html values from plain string. -
implicit
class
SeqHtmlExtensions extends AnyRef
Extension methods for
Seq[Html]
. -
implicit
class
SeqHtmlExtensions0[A] extends AnyRef
Extension methods for
Seq[_]
. -
implicit
class
TemplateInterpolation extends AnyRef
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.
-
trait
ToHtml[-A] extends AnyRef
A type class to provide Html rendering.
Value Members
-
implicit
def
toHtml[A](value: A)(implicit arg0: ToHtml[A]): Html
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, whileNone
produces an empty string.scala.Unit
produces an empty string.scala.Seq
outputs every item without any separator.
-
object
Html extends Serializable
Provides the
ContentEncoder
for HTML documents. -
object
ToHtml
Default instances for the ToHtml type class.