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.
Dernier runRéussi#125 · main · 16 min 13 s
0Étoiles
0Forks
40Issues
| 1 | import std/html.{type Html} |
| 2 | import std/io |
| 3 | import std/template.{html, render_xml, xml} |
| 4 | |
| 5 | fn card :: title: String body: Html -> Html |
| 6 | { |
| 7 | html`<section class="card"><h2>{title}</h2>{body}</section>` |
| 8 | } |
| 9 | |
| 10 | pub 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 <&">!</p> |
| 23 | //> <p>count: 5, debug: "Ada <&\">"</p> |
| 24 | //> <ul><li>one</li><li>two</li></ul> |
| 25 | //> <section class="card"><h2>T <&</h2><p>body</p></section> |
| 26 | //> <item id="Ada <&">"/> |
| 27 | //> <p>nested: <b>x</b></p> |