annotate website/src/examples/hi2_simply_html.luan @ 388:12ee9a336b95

add more examples
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 23 Apr 2015 18:54:35 -0600
parents website/src/examples/hi2.luan@8557581740db
children 2f5cc9c2cbf0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
382
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Io = require "luan:Io"
388
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
2 local Html = require "luan:Html"
382
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local Http = require "luan:web/Http"
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5
388
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
6 local function form() %>
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
7 <form>
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
8 <label>What is you name?</label>
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
9 <input name="name" margin-bottom="1em">
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
10 <input type=submit>
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
11 </form>
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
12 <% end
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
13
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
14 local function hello() %>
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
15 <p>Hi <%= name %>!</p>
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
16 <% end
382
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 function service()
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 Io.stdout = Http.response.text_writer()
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 name = Http.request.parameters.name
388
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
21 Html.simply_html_page{
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
22 body = function() %>
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
23 <div container>
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
24 <h1 margin-bottom="1em">Hello</h1>
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
25 <%
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
26 if name == nil then
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
27 form()
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
28 else
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
29 hello()
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
30 end
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
31 %>
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
32 <p margin-top="2em"><small>This page was made with <a href="http://www.simplyhtml.org/">SimplyHTML</a>.</small></p>
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
33 </div>
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
34 <% end;
12ee9a336b95 add more examples
Franklin Schmidt <fschmidt@gmail.com>
parents: 382
diff changeset
35 }
382
8557581740db added tutorial
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 end