Mercurial Hosting > luan
comparison src/luan/modules/Html.luan @ 1798:f8eba0442956
use backticks
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 22 Feb 2024 08:08:07 -0700 |
parents | 36c28be6d432 |
children |
comparison
equal
deleted
inserted
replaced
1797:ba43135bb98d | 1798:f8eba0442956 |
---|---|
6 local Luan = require "luan:Luan.luan" | 6 local Luan = require "luan:Luan.luan" |
7 local error = Luan.error | 7 local error = Luan.error |
8 local ipairs = Luan.ipairs or error() | 8 local ipairs = Luan.ipairs or error() |
9 local pairs = Luan.pairs or error() | 9 local pairs = Luan.pairs or error() |
10 local type = Luan.type or error() | 10 local type = Luan.type or error() |
11 local Io = require "luan:Io.luan" | |
12 local output_of = Io.output_of or error() | |
13 | 11 |
14 | 12 |
15 local Html = {} | 13 local Html = {} |
16 | 14 |
17 Html.decode = HtmlLuan.decode | 15 Html.decode = HtmlLuan.decode |
46 end | 44 end |
47 %>><% | 45 %>><% |
48 end | 46 end |
49 | 47 |
50 function Html.to_string(list) | 48 function Html.to_string(list) |
51 return output_of( function() | 49 return ` |
52 for _, obj in ipairs(list) do | 50 for _, obj in ipairs(list) do |
53 local tp = type(obj) | 51 local tp = type(obj) |
54 if tp == "string" then | 52 if tp == "string" then |
55 %><%= encode(obj) %><% | 53 %><%= encode(obj) %><% |
56 elseif tp == "table" then | 54 elseif tp == "table" then |
72 end | 70 end |
73 else | 71 else |
74 error("invalid value ("..tp..") in list for 'Html.to_string'") | 72 error("invalid value ("..tp..") in list for 'Html.to_string'") |
75 end | 73 end |
76 end | 74 end |
77 end ) | 75 ` |
78 end | 76 end |
79 | 77 |
80 return Html | 78 return Html |