tobogganSe connecter

louise

The Louise language: compiler, runtime, std, tooling

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

63 lignes · 2073 octetsBrut · Historique
1import std/html.{type Html}
2import std/io
3import std/template.{pug}
4
5fn layout :: title: String content: Html -> Html
6{
7 pug`
8 html
9 body.main
10 h1#top {title}
11 | byline
12 // a comment
13 .content
14 {content}
15 `
16}
17
18pub fn main :: -> () / <io>
19{
20 io.println (html.render pug`.card`)
21 io.println (html.render pug`h1.title Hello, {"Ada & <Co>"}!`)
22 io.println (html.render pug`a(href="/x?y={1 + 1}" class="link") go`)
23 io.println (html.render pug`input(type="text" disabled)`)
24 io.println (html.render pug`p count: {40 + 2}`)
25 io.println (html.render pug`p before {pug`b inside`} after`)
26 io.println (html.render (layout "A & B" pug`p <not-a-tag>`))
27 // Bool attribute holes are flags (present iff true), `Option<String>`
28 // is absent for `None` (ADR 0057).
29 let on = True
30 let off = False
31 let none: Option<String> = None
32 io.println
33 (html.render pug`input(required={on} autofocus={off} value={none})`)
34 io.println
35 ( html.render
36 pug`
37 ul
38 li one
39 li two
40 p.after done
41 `
42 )
43 // Attribute names take `:` and `.`, as a literal's do (issue #300):
44 // htmx 4's modifiers, Alpine's directives; tag names take `:`.
45 io.println
46 ( html.render
47 pug`section#shelf(hx-target:inherited="#shelf" hx-status:422="target:#composer")`
48 )
49 io.println (html.render pug`button(x-on:click.prevent="save()") save`)
50 io.println (html.render pug`svg:rect(width="1")`)
51}
52//> <div class="card"></div>
53//> <h1 class="title">Hello, Ada &amp; &lt;Co&gt;!</h1>
54//> <a href="/x?y=2" class="link">go</a>
55//> <input type="text" disabled>
56//> <p>count: 42</p>
57//> <p>before <b>inside</b> after</p>
58//> <html><body class="main"><h1 id="top">A &amp; B</h1>byline<div class="content"><p>&lt;not-a-tag&gt;</p></div></body></html>
59//> <input required>
60//> <ul><li>one</li><li>two</li></ul><p class="after">done</p>
61//> <section id="shelf" hx-target:inherited="#shelf" hx-status:422="target:#composer"></section>
62//> <button x-on:click.prevent="save()">save</button>
63//> <svg:rect width="1"></svg:rect>