luci-theme-openwrt-2020: honor CSS definitions passed by views
authorJo-Philipp Wich <jo@mein.io>
Fri, 9 Apr 2021 12:25:51 +0000 (14:25 +0200)
committerJo-Philipp Wich <jo@mein.io>
Fri, 9 Apr 2021 12:29:12 +0000 (14:29 +0200)
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>
themes/luci-theme-openwrt-2020/luasrc/view/themes/openwrt2020/header.htm

index f6ae02c212abf585e29795ef3f93c1be4d398bad..6370ee4d1f9c82376bebdd512eff190baee1ac3c 100644 (file)
 <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) %>">