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.

27 lignes · 992 octetsBrut · Historique
1import std/html.{type Html}
2import std/io
3import std/template.{html, render_xml, xml}
4
5fn card :: title: String body: Html -> Html
6{
7 html`<section class="card"><h2>{title}</h2>{body}</section>`
8}
9
10pub fn main :: -> () / <io>
11{
12 let name = "Ada <&\">"
13 io.println (html.render html`<p>Hello, {name}!</p>`)
14 io.println (html.render html`<p>count: {2 + 3}, debug: {name:?}</p>`)
15 let items: List<Html> = [html`<li>one</li>`, html`<li>two</li>`]
16 io.println (html.render html`<ul>{items}</ul>`)
17 io.println (html.render (card "T <&" html`<p>body</p>`))
18 io.println (render_xml xml`<item id="{name}"/>`)
19 io.println
20 (html.render html`<p>{"nested: " <> html.render html`<b>x</b>`}</p>`)
21}
22//> <p>Hello, Ada &lt;&amp;&quot;&gt;!</p>
23//> <p>count: 5, debug: &quot;Ada &lt;&amp;\&quot;&gt;&quot;</p>
24//> <ul><li>one</li><li>two</li></ul>
25//> <section class="card"><h2>T &lt;&amp;</h2><p>body</p></section>
26//> <item id="Ada &lt;&amp;&quot;&gt;"/>
27//> <p>nested: &lt;b&gt;x&lt;/b&gt;</p>