我正在使用Mako模板进行项目.如何在Mako中添加CSS文件?
我尝试使用< link type =“stylesheet”type =“text / css”href =“<%include file =’test.css’/>” />在< head>中标签,但它不起作用.
最佳答案 怎么样
${css_link('/css/filename.css', 'screen')}
完整的示例代码:
<% self.seen_css = set() %>
<head>
${self.css()}
</head>
<%def name="css_link(path, media='')">
% if path not in self.seen_css:
<link rel="stylesheet" type="text/css" href="${path|h}" media="${media}"></link>
% endif
<% self.seen_scripts.add(path) %>
</%def>
<%def name="css()">
${css_link('/css/main.css', 'screen')}
${css_link('/css/navigation.css', 'screen')}
${css_link('/css/forms-buttons.css', 'screen')}
${css_link('/css/orders.css', 'screen')}
</%def>