@lunelson/sass-throw

2.1.0 • Public • Published

Sass Throw

Functions for using Sass' @error @warn and @debug directives in a way that is capturable and testable.

Installation

# install in your project

npm i @lunelson/sass-throw

Basic Usage

The basic API consists of the following functions and mixins, which receive a string, and will trigger their corresponding directive (e.g. @warn) with the given string when the $throw-catch global variable is false, but will return the string when $throw-catch is true.

// Sass input file
// NB: you need 'node_modules' in Sass' `importPaths` option

@import '@lunelson/sass-throw/index';

$throw-catch: true;

.test {
  error: throw-error('this is an error message via function');
  warn: throw-warn('this is a warn message via function');
  debug: throw-debug('this is a debug message via function');
}

@include throw-error('this is an error message via mixin');
@include throw-warn('this is a warn message via mixin');
@include throw-debug('this is a debug message via mixin');
/* CSS output file */

.test {
  error: "this is an error message via function";
  warn: "this is a warn message via function";
  debug: "this is a debug message via function";
}

.sass-throw .error {
  message: "this is an error message via mixin";
}

.sass-throw .warn {
  message: "this is a warn message via mixin";
}

.sass-throw .debug {
  message: "this is a debug message via mixin";
}

Questions? File an issue, or tweet at me.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.1.032latest
2.0.0-rc.40next

Version History

VersionDownloads (Last 7 Days)Published
2.1.032
2.0.0-rc.40
2.0.0-rc.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i @lunelson/sass-throw

Weekly Downloads

32

Version

2.1.0

License

MIT

Unpacked Size

9.25 kB

Total Files

7

Last publish

Collaborators

  • lunelson