JigSass Tools Strings

NPM version Dependency Status

String manipulation helper functions

Installation

Using npm:

npm i -S jigsass-tools-strings

Usage

@import 'path/to/jigsass-tools-strings';

License: MIT

strings

variables

jigsass-str-to-number-suppress-warning

$jigsass-str-to-number-suppress-warning: false !default;

Description

Determines if jigsass-str-to-number will warn when a string cannot be converted to a number

Type

Boolean

Used by

functions

jigsass-str-to-number

@function jigsass-str-to-number($number-string) { ... }

Description

Convert a string representing a number into an actual number

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$number-stringnoneStringnone

Returns

Number

Requires

jigsass-str-trim

@function jigsass-str-trim($string, $leading: true, $trailing: true) { ... }

Description

Trim whitespace from a string

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$stringnoneStringnone
$leadingnoneBooleantrue
$trailing

Indicates if trailing whitespace will be removed

Booleantrue

Returns

String

The trimmed string

Used by

jigsass-str-split

@function jigsass-str-split($string, $separator: false, $limit: false) { ... }

Description

Split a string into a list of strings by separating it into substrings. A sass implementation of Javascript's String.prototype.split() sans the ability to pass a regular expression as the separator.

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$string

The string to split

Stringnone
$separator

Specifies the character(s) to use for separating the string. If $separator is omitted, the List returned contains one item consisting of the entire string. If $separator is an empty string, the string is converted to a list of characters.

Stringfalse
$limit

Integer specifying a limit on the number of splits to be found. jigsass-str-split will splits on every match of separator, until the number of split items match the limit or the string falls short of separator.

Number or Booleanfalse

Returns

List

Requires

jigsass-str-replace

@function jigsass-str-replace($string, $substr, $new-substr, $replace-all, $match-case) { ... }

Description

Replace a substring inside a string

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$string

The string to search in

Stringnone
$substr

The substring to search for

Stringnone
$new-substr

The substring to replace $substr with

Stringnone
$replace-all

Replace all instances of $substr, or just the first

Booleannone
$match-casenoneBooleannone

Returns

String

The replaced string

Used by

jigsass-str-escape

@function jigsass-str-escape($str) { ... }

Description

Escape special characters in a string.

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$str

The string to escape

Stringnone

Returns

String

The escaped string

Requires

jigsass-svg-encode

@function jigsass-svg-encode($svg-string) { ... }

Description

Encode an svg string so that it can be used in CSS cross browser with the smallest footprint

Parameters

parameterNameparameterDescriptionparameterTypeparameterDefault value
$svg-string

The string to encode

Stringnone

Returns

String

The encoded svg inside a url function, for use in content or background-image

Requires