Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

HTML views

File templates under app/views/**/*.html — Blade-near, intentionally small.

API

APIMeaning
view(path, data)Render file → HTML response (200)
view(path, data, status)Same with status
render_view(path, data)Render → string
html(body)HTML response from a string
render_template(tpl, data)Inline string template

Paths are relative to app/views/ ("hello/show"hello/show.html).

Requires running against a project directory (atlantus dev --path …).

Handler

get "/hello/{name}" {
  def hello_name(req) {
    let name = req.param("name")
    return view("hello/show", { "name": name })
  }
}

Template syntax

ConstructEffect
{{ key }}HTML-escaped
{{{ key }}}Raw
{{-- comment --}}Stripped
@if(x) / @else / @endifConditional
@foreach(list as item) / @endforeachLoop
@extends("layouts/app")Layout
@section("content")@endsectionSection
@yield("content")Layout hole
@include("partials/nav")Partial

Layout example

app/views/layouts/app.html:

<!DOCTYPE html>
<html>
<body>
  @include("partials/nav")
  <main>@yield("content")</main>
</body>
</html>

app/views/hello/show.html:

@extends("layouts/app")
@section("content")
<h1>Hello, {{ name }}!</h1>
@endsection

Principles

  • Escape by default
  • Views are pure (no DB) — handlers pass data maps
  • Prefer file views for real pages

Try it with atlantus dev after adding routes + templates.

Next: Built-in API.