javascript - Jade conditional based on page url? -


is possible setup jade conditional in layout template based on page path? there page path variable? looking things like:

if page = "/about"   link(rel='stylesheet', href='css/about') else   link(rel='stylesheet', href='css/main') 

where part of layout template. , how define variables drive this?

yes, possible:

- var page = window.location.pathname  if page === "/about"    link(rel='stylesheet', href='css/about.css') else    link(rel='stylesheet', href='css/main.css') 

please note above snippet assumes template executed in browser environment. if not case, can pathname using language using , pass template datum. example, if using express framework, path property of request object returns path part of url.


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -