delphimvcframework/redist/Lua/html/form.lua

40 lines
905 B
Lua
Raw Normal View History

2013-10-29 17:36:46 +01:00
html = {}
2013-11-11 13:52:33 +01:00
local function join_tables(t1, t2)
local t1 = t1 or {}
local t2 = t2 or {}
for k,v in pairs(t2) do
t1[k] = v
end
return t1
end
local function tag(tagname, systemopts, useropts)
local opts = join_tables(systemopts, useropts)
local s = '<' .. tagname .. ' '
for k,v in pairs(opts) do
s = s .. string.format('%s="%s" ', k,v)
end
s = s .. ">"
return s
end
function html:input(type, value, useropts)
return tag('input', {["type"]= type, ["value"] = value}, useropts)
end
function html:submit(value, useropts)
return tag('input', {["type"]= "submit", ["value"] = value}, useropts)
end
function html:button(value, useropts)
return tag('input', {["type"]= "button", ["value"] = value}, useropts)
end
function html:form_start(opts, useropts)
return tag('form', opts, {})
end
function html:form_end()
return "</form>"
2013-10-29 17:36:46 +01:00
end