Skip to content

Scalatags HTML templating integration #184

@vim89

Description

@vim89

Problem

Cask has no built-in HTML templating. Users must manually construct HTML responses or integrate third-party template engines.

// Current - manual HTML strings (bad)
@cask.get("/")
def index() = {
  """
  <html>
    <body>
      <h1>Welcome</h1>
    </body>
  </html>
  """
}

// Or raw Scalatags (works, but no defaults)
@cask.get("/")
def index() = {
  import scalatags.Text.all._
  html(
    body(
      h1("Welcome")
    )
  ).render
}
  • No default HTML templating approach
  • No type-safe HTML rendering pattern
  • No visibility: examples & scalatags in ecosystem

Solution

simple Scalatags integration as the default HTML templating approach

  • import for Scalatags in cask
  • return Scalatags as HTML response
  • Common patterns HMTL layouts

Questions -

  • HTML mixed with Scala code - please advice something on separation
  • CSS/JS integration - another probelm / concern
  • Package cask.scalatags or cask.html ?
  • Error pages for 404/500?

References

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions