comparison website/src/examples/hi2_simply_html.luan @ 505:7bc63886d4f2

web page modules now return a function
author Franklin Schmidt <fschmidt@gmail.com>
date Thu, 21 May 2015 01:45:49 -0600
parents 92c3d22745b8
children
comparison
equal deleted inserted replaced
504:dbdf4b8193a8 505:7bc63886d4f2
1 local Io = require "luan:Io" 1 local Io = require "luan:Io"
2 local Html = require "luan:Html" 2 local Html = require "luan:Html"
3 local Http = require "luan:http/Http" 3 local Http = require "luan:http/Http"
4 4
5 local M = {}
6 5
7 local function form() %> 6 local function form() %>
8 <form> 7 <form>
9 <label>What is your name?</label> 8 <label>What is your name?</label>
10 <input name="name" margin-bottom="1em"> 9 <input name="name" margin-bottom="1em">
16 local function hello(name) %> 15 local function hello(name) %>
17 <p>Hi <%= name %>!</p> 16 <p>Hi <%= name %>!</p>
18 <% end 17 <% end
19 18
20 19
21 function M.respond() 20 return function()
22 Io.stdout = Http.response.text_writer() 21 Io.stdout = Http.response.text_writer()
23 local name = Http.request.parameter.name 22 local name = Http.request.parameter.name
24 %> 23 %>
25 <html> 24 <html>
26 <head> 25 <head>
41 <% Html.simply_html_body_bottom() %> 40 <% Html.simply_html_body_bottom() %>
42 </body> 41 </body>
43 </html> 42 </html>
44 <% 43 <%
45 end 44 end
46
47 return M