Videl Videl - 1 year ago 125
Sass (Sass) Question

Sass - How to Import a Message into Directive

I use

a lot, but I'd like to import pre-written messages into my warnings that are stored for example in another function or file.

Is this possible?

I know the following won't work, but so you get the idea...

@if $a == 'red' {
color: red;
} @else if $a == 'blue' {
color: blue;
} @else {
@warn '@include error-msg_no-color-detected';

Answer Source

This can be done using variables...

$msg: 'Something went wrong!';

@if ... {
} @else {
    @warn: '#{$msg}';

This allows me to create a _debug.scss file containing lots of messages.

@import 'config';
@import 'debug';
@import 'dark';
@import 'application';


@msg-1: 'Oops!';
@msg-2: 'No color defined. Check the config file.';
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download