I want to use SASS in a modular way. In the code segment below you can see a way I consider organizing some of the layouts of a page.
What I have in mind is the external variables in languages like C.
// file: some_page.scss // // I want some variables from the fonts, colors partials // to be visible to the buttons partial // Is it possible? // error: _buttons.scss (Line X: Undefined variable: "$color_blue") @import "colors" @import "fonts" @import "buttons" // in file: _colors.scss $color_blue: blue; // in file: _buttons.scss .button { background-color: $color_blue; }
To use global variables between files in Python, we can use the global keyword to define a global variable in a module file. Then we can import the module in another module and reference the global variable directly. We import the settings and subfile modules in main.py . Then we call settings.
We can create a config file & store the entire global variable to be shared across modules or script in it. By simply importing config, the entire global variable defined it will be available for use in other modules.
It is impossible to globalise a variable inside a function in a separate file.
Yes, that's how it works.
As long as _colors.scss
is imported before the other files.
You can check out the port of Twitter Bootstrap to Sass here: https://github.com/thomas-mcdonald/bootstrap-sass it uses variables in a similar fashion.
You need to add a ;
at the end of the @import
line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With