Sometimes your app can use several CSS framework.
By example you used a specific one for your landing page, say bulma. Then your designer send you a bootstrap one for the whole website.
It's now possible to assign a page builder per layout.
Page builders are partials to generate your content from the html widget.
This small update allow you more flexibility.
The default one is still the default 'page' one defined on installation process.
By default, the default theme use the bulma CSS framework ... But you can use any framework you want.
I hope you'll like this new feature ;)
Here the default page partial.
<%
function check_content(data)
if type(data.content) == "table" then
data = data.content
else
data = { data }
end
return data
end
function render_bulma(data, default_container_class, row_set)
out = '' -- to_json(data)
for k, widget in pairs(data) do
local content = ''
local attr = {}
local row_class = ''
local container_class = default_container_class
if widget.data then
if next(widget.data[1]) ~= nil then
content = widget.data[1][1].content
attr = widget.data[1][1].attr
end
else
content = widget.content
attr = widget.attr
end
if (attr) then
if(attr['row-class']) then row_class = attr['row-class'] end
if(attr['container-class']) then container_class = attr['container-class'] end
if(container_class == "") then container_class = default_container_class end
end
if (row_set) then row_class = "" end
out = out .. '<div class="' .. row_class .. ' "><div class="' .. container_class .. ' ">'
-- out = out .. '<div>' .. widget.type .. '</div>'
if widget.type == 'h1' then
out = out .. "<" .. widget.type .. ">" .. content .. "</" .. widget.type .. ">"
end
if widget.type == 'h2' then
out = out .. "<" .. widget.type .. ">" .. content .. "</" .. widget.type .. ">"
end
if widget.type == 'h3' then
out = out .. "<" .. widget.type .. ">" .. content .. "</" .. widget.type .. ">"
end
if widget.type == 'h4' then
out = out .. "<" .. widget.type .. "'>" .. content .. "</" .. widget.type .. ">"
end
if widget.type == 'h5' then
out = out .. "<" .. widget.type .. ">" .. content .. "</" .. widget.type .. ">"
end
if widget.type == 'h6' then
out = out .. "<" .. widget.type .. ">" .. content .. "</" .. widget.type .. ">"
end
if widget.type == 'text' or widget.type == 'img' or widget.type == 'code' or widget.type == 'embed' then
out = out .. content
end
if widget.type == 'col48' then
out = out .. '<div class="row">'
out = out .. '<div class="col-4">'
for k, sub_row in pairs(widget.data[1]) do
sub_row = check_content(sub_row)
out = out .. render_bulma(sub_row, "", true)
end
out = out .. '</div>'
out = out .. '<div class="col-8">'
for k, sub_row in pairs(widget.data[2]) do
sub_row = check_content(sub_row)
out = out .. render_bulma(sub_row, "", true)
end
out = out .. '</div>'
out = out .. '</div>'
end
if widget.type == 'col84' then
out = out .. '<div class="row">'
out = out .. '<div class="col-8">'
for k, sub_row in pairs(widget.data[1]) do
sub_row = check_content(sub_row)
out = out .. render_bulma(sub_row, "", true)
end
out = out .. '</div>'
out = out .. '<div class="col-4">'
for k, sub_row in pairs(widget.data[2]) do
sub_row = check_content(sub_row)
out = out .. render_bulma(sub_row, "", true)
end
out = out .. '</div>'
out = out .. '</div>'
end
if widget.type == 'col363' then
out = out .. '<div class="row">'
out = out .. '<div class="col-3">'
for k, sub_row in pairs(widget.data[1]) do
sub_row = check_content(sub_row)
out = out .. render_bulma(sub_row, "", true)
end
out = out .. '</div>'
out = out .. '<div class="col-6">'
for k, sub_row in pairs(widget.data[2]) do
sub_row = check_content(sub_row)
out = out .. render_bulma(sub_row, "", true)
end
out = out .. '</div>'
out = out .. '<div class="col-3">'
for k, sub_row in pairs(widget.data[3]) do
sub_row = check_content(sub_row)
out = out .. render_bulma(sub_row, "", true)
end
out = out .. '</div>'
out = out .. '</div>'
end
if widget.type == 'col2' then
out = out .. '<div class="row">'
out = out .. '<div class="col">'
for k, sub_row in pairs(widget.data[1]) do
sub_row = check_content(sub_row)
out = out .. render_bulma(sub_row, "", true)
end
out = out .. '</div>'
out = out .. '<div class="col">'
for k, sub_row in pairs(widget.data[2]) do
sub_row = check_content(sub_row)
out = out .. render_bulma(sub_row, "", true)
end
out = out .. '</div>'
out = out .. '</div>'
end
if widget.type == 'col3' then
out = out .. '<div class="row">'
out = out .. '<div class="col">'
for k, sub_row in pairs(widget.data[1]) do
sub_row = check_content(sub_row)
out = out .. render_bulma(sub_row, "", true)
end
out = out .. '</div>'
out = out .. '<div class="col">'
for k, sub_row in pairs(widget.data[2]) do
sub_row = check_content(sub_row)
out = out .. render_bulma(sub_row, "", true)
end
out = out .. '</div>'
out = out .. '<div class="col">'
for k, sub_row in pairs(widget.data[3]) do
sub_row = check_content(sub_row)
out = out .. render_bulma(sub_row, "", true)
end
out = out .. '</div>'
out = out .. '</div>'
end
if widget.type == 'col4' then
out = out .. '<div class="row">'
out = out .. '<div class="col">'
for k, sub_row in pairs(widget.data[1]) do
sub_row = check_content(sub_row)
out = out .. render_bulma(sub_row, "", true)
end
out = out .. '</div>'
out = out .. '<div class="col">'
for k, sub_row in pairs(widget.data[2]) do
sub_row = check_content(sub_row)
out = out .. render_bulma(sub_row, "", true)
end
out = out .. '</div>'
out = out .. '<div class="col">'
for k, sub_row in pairs(widget.data[3]) do
sub_row = check_content(sub_row)
out = out .. render_bulma(sub_row, "", true)
end
out = out .. '</div>'
out = out .. '<div class="col">'
for k, sub_row in pairs(widget.data[4]) do
sub_row = check_content(sub_row)
out = out .. render_bulma(sub_row, "", true)
end
out = out .. '</div>'
out = out .. '</div>'
end
out = out .. "</div></div>"
end
return out
end
%>
<%- render_bulma(dataset, "container", false) %>