I'm converting a static HTML page to a Flask application which would dynamically change its CSS file depending on the screen size. However when switching to Flask, I have to grab URLs for a file in a HTML files like this:
<link rel="stylesheet" href="{{ url_for('static', filename='css/style.css') }}"/>
However in my Javascript init.js I have this code to switch between CSS files.
(function($) {
skel.init({
reset: 'full',
breakpoints: {
'global': { range: '*', href: 'static/css/style.css', containers: 1400, grid: { gutters: 40 }, viewport: { scalable: false } },
'wide': { range: '961-1880', href: 'static/css/style-wide.css', containers: 1200, grid: { gutters: 40 } },
'normal': { range: '961-1620', href: 'static/css/style-normal.css', containers: 960, grid: { gutters: 40 } },
'narrow': { range: '961-1320', href: 'static/css/style-narrow.css', containers: '100%', grid: { gutters: 20 } },
'narrower': { range: '-960', href: 'static/css/style-narrower.css', containers: '100%', grid: { gutters: 15 } },
'mobile': { range: '-736', href: 'static/css/style-mobile.css', grid: { collapse: true } }
},
plugins: {
layers: {
sidePanel: {
hidden: true,
breakpoints: 'narrower',
position: 'top-left',
side: 'left',
animation: 'pushX',
width: 240,
height: '100%',
clickToHide: true,
html: '<div data-action="moveElement" data-args="header"></div>',
orientation: 'vertical'
},
sidePanelToggle: {
breakpoints: 'narrower',
position: 'top-left',
side: 'top',
height: '4em',
width: '5em',
html: '<div data-action="toggleLayer" data-args="sidePanel" class="toggle"></div>'
}
}
}
});
I'm not able to put a {{ url_for('static', filename='css/style.css')}} inside of Javascript. Is there any way I can do this?