local view = ...
local function packURL(script, prefix, controller, action, extra)
ret = script .. "/" .. prefix .. controller .. "/" .. action
sep = '?'
for k,v in pairs(extra) do
ret = ret .. sep .. k .. '=' .. v
sep = '&'
end
return ret
end
--[[
view
script, prefix, controller
action[]
name, script, prefix, controller
section
id
label
disabled
active
id
action
title
text[]
label
content
--]]
?>
= view.title
?>
--Status Block
for i,item in ipairs(view.note or {}) do
?>= item.content ?>
end
local section = ""
for i,item in ipairs(view.action) do
if section ~= item.section then
section = item.section
?>= section ?>
end
if item.disabled then
?>= item.label or item.name ?>
else
?>= html.form.start {
method="POST",
action = packURL(item.script or view.script,
item.prefix or view.prefix,
item.controller or view.controller,
item.name, {})
} ?>= html.form.hidden { name="id", value=item.id } ?>
local label = (item.label or item.name)
if item.id == view.active.id and item.name == view.active.action then
label = '['..label..']'
end
?>= html.form.submit {
name = item.name, value = label
} ?>= html.form.stop() ?>
end
end
for i,item in ipairs(view.text) do
if item.label then
?>= item.label ?>
end
?>= item.content ?>
end
-- vim: set filetype=lua :
?>