How to include CSS file in Mako?

I use the Mako template for the project. How to add CSS file in Mako?

I am trying to use <link type="stylesheet" type="text/css" href="<%include file='test.css' />" /> in the <head> , but it does not work.

+4
source share
1 answer

What about

 ${css_link('/css/filename.css', 'screen')} 

Source: http://wiki.pylonshq.com/display/pylonscookbook/Including+CSS+And+Javascript+(etc.)+In+A+Flexible+Way+With+Mako

Full Code Code:

 <% 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> 
+2
source

Source: https://habr.com/ru/post/1380299/


All Articles