Browse Source

luci-theme-openwrt-2020: honor CSS definitions passed by views

Legacy Lua views might declare a global `css` variable to inject custom
styles into the template header. Support this mechanism in the OpenWrt 2020
theme as well.

Ref: https://github.com/openwrt/luci/issues/4972
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Jo-Philipp Wich 3 years ago
parent
commit
c5ff3244e9

+ 4 - 0
themes/luci-theme-openwrt-2020/luasrc/view/themes/openwrt2020/header.htm

@@ -28,6 +28,10 @@
 <script type="text/javascript" src="<%=url('admin/translations', luci.i18n.context.lang)%><%# ?v=PKG_VERSION %>"></script>
 <script type="text/javascript" src="<%=resource%>/cbi.js"></script>
 <title><%=striptags( (boardinfo.hostname or "?") .. ( (node and node.title) and ' - ' .. translate(node.title) or '')) %> - LuCI</title>
+<% if css then %><style title="text/css">
+<%= css %>
+</style>
+<% end -%>
 </head>
 <body class="lang_<%=luci.i18n.context.lang%>" data-page="<%= pcdata(path) %>">