added template.render function

This commit is contained in:
gabryon99 2021-03-05 11:47:59 +01:00
parent fc3d065180
commit 30bf1e5589
2 changed files with 13 additions and 2 deletions

View file

@ -43,4 +43,12 @@ function template.gen(template_file, context, is_full_path)
return template.compile(path, nil, nil)(context)
end
---Print the template inside the requested page
---@param template_file string The template file to render
---@param context table The data used by the page template
---@param is_full_path boolean Is an absolute path?
function template.render(template_file, context, is_full_path)
print(template.gen(template_file, context, is_full_path))
end
return template

View file

@ -10,7 +10,6 @@ local template_utils = require("template_utils")
local ui_utils = {}
function ui_utils.render_configuration_footer(item)
return template_utils.gen('pages/components/manage-configuration-link.template', {item = item})
end
@ -63,9 +62,13 @@ function ui_utils.render_pools_dropdown(pools_instance, member, key)
end
function ui_utils.create_navbar_title(title, subpage, title_link)
if isEmptyString(subpage) then return title end
return "<a href='".. title_link .."'>".. title .. "</a>&nbsp;/&nbsp;<span>"..subpage.."</span>"
end
--- Shortcut function to print a togglw switch inside the requested page
function ui_utils.print_toggle_switch(context)
print(template_utils.gen("on_off_switch.html", context))
end
return ui_utils