comparison src/luan/modules/Html.luan @ 1088:bae2d0c2576c

change module naming convention
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 26 Dec 2016 22:29:36 -0700
parents 1a68fc55a80c
children 2bbc6f132d61
comparison
equal deleted inserted replaced
1087:4aab4dd3ac9c 1088:bae2d0c2576c
9 local type = Luan.type or error() 9 local type = Luan.type or error()
10 local Io = require "luan:Io.luan" 10 local Io = require "luan:Io.luan"
11 local output_of = Io.output_of or error() 11 local output_of = Io.output_of or error()
12 12
13 13
14 local M = {} 14 local Html = {}
15 15
16 M.encode = HtmlLuan.encode 16 Html.encode = HtmlLuan.encode
17 17
18 local quote = HtmlLuan.quote 18 local quote = HtmlLuan.quote
19 M.quote = quote 19 Html.quote = quote
20 20
21 function M.parse(text,container_tags) 21 function Html.parse(text,container_tags)
22 text or error "text required" 22 text or error "text required"
23 container_tags = container_tags or {"script","style","textarea"} 23 container_tags = container_tags or {"script","style","textarea"}
24 return HtmlParser.toList(text,container_tags) 24 return HtmlParser.toList(text,container_tags)
25 end 25 end
26 26
27 function M.url_encode(s) 27 function Html.url_encode(s)
28 return URLEncoder.encode(s,"UTF-8") 28 return URLEncoder.encode(s,"UTF-8")
29 end 29 end
30 30
31 local function output_tag(tag) 31 local function output_tag(tag)
32 %><<%= tag.name %><% 32 %><<%= tag.name %><%
41 %>/<% 41 %>/<%
42 end 42 end
43 %>><% 43 %>><%
44 end 44 end
45 45
46 function M.to_string(list) 46 function Html.to_string(list)
47 return output_of( function() 47 return output_of( function()
48 for _, obj in ipairs(list) do 48 for _, obj in ipairs(list) do
49 local tp = type(obj) 49 local tp = type(obj)
50 if tp == "string" then 50 if tp == "string" then
51 %><%= obj %><% 51 %><%= obj %><%
71 end 71 end
72 end 72 end
73 end ) 73 end )
74 end 74 end
75 75
76 return M 76 return Html