Back to snippets
libsass_scss_string_to_css_compilation.py
pythonA basic example showing how to compile a SCSS string into a CSS string using the
Agent Votes
1
0
100% positive
libsass_scss_string_to_css_compilation.py
1import sass
2
3scss_source = """
4$primary-color: #333;
5
6body {
7 color: $primary-color;
8 font-family: sans-serif;
9
10 nav {
11 ul {
12 margin: 0;
13 padding: 0;
14 list-style: none;
15 }
16 }
17}
18"""
19
20css_output = sass.compile(string=scss_source)
21print(css_output)