From 18730047b274938e761a5074671f38371fff5b5c Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Mon, 27 Feb 2017 16:14:04 +0000 Subject: Modify htmlviewfunctions to output item class for static content Previously, class was not output unless item was in a form (cherry picked from commit 48eeb5f3317a39fac1e821305e1e76975bccb5ca) --- lib/htmlviewfunctions.lua | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/htmlviewfunctions.lua b/lib/htmlviewfunctions.lua index cd5774c..3eef7d9 100644 --- a/lib/htmlviewfunctions.lua +++ b/lib/htmlviewfunctions.lua @@ -124,15 +124,23 @@ function mymodule.displayitem(myitem, page_info, header_level, name, group) elseif myitem.key and not myitem.readonly then mymodule.displayformitem(myitem, name, header_level, group) elseif myitem.type ~= "hidden" then - if myitem.errtxt then - myitem.class = "error" + if myitem.errtxt then + if myitem.class then + myitem.class = myitem.class.." error" + else + myitem.class = "error" + end end header_level = mymodule.displayitemstart(myitem, page_info, header_level) if 0 <= header_level then io.write(html.html_escape(myitem.label)) end mymodule.displayitemmiddle(myitem, page_info, header_level) - io.write("

"..string.gsub(html.html_escape(tostring(myitem.value)), "\n", "
") .. "

\n") + class = "" + if myitem.class then + class = ' class="'..html.html_escape(myitem.class)..'"' + end + io.write(""..string.gsub(html.html_escape(tostring(myitem.value)), "\n", "
") .. "

\n") mymodule.displayitemend(myitem, page_info, header_level) end end @@ -141,8 +149,12 @@ function mymodule.displayformitem(myitem, name, header_level, group) if not myitem then return end myitem.name = name or myitem.name or "" if group and group ~= "" then myitem.name = group.."."..myitem.name end - if myitem.errtxt then - myitem.class = "error" + if myitem.errtxt then + if myitem.class then + myitem.class = myitem.class.." error" + else + myitem.class = "error" + end end if myitem.type ~= "hidden" and myitem.type ~= "group" then -- Set the id so the label 'for' can point to it -- cgit v1.2.3