class

Hwaro::Assets::Sass::Str

Inherits Hwaro::Assets::Sass::Value < Reference < Object

Constructors

new(text : String, quoted : Bool, quote_char : Char = '"')
Source

Class methods

contains_unescaped?(text : String, quote : Char) : Bool
Source
decode(text : String) : String
Source
encode(decoded : String) : String

Inverse of decode for a computed result: backslashes and unprintable / private-use code points are escaped (an icon-font glyph stays \e900), everything else is kept literal. A quote needs no escape here — to_css picks a quote that fits.

Source
join_text(left : String, right : String) : String

a + b on string text: a trailing hex escape would swallow a following hex digit ("\f101" + "a" must stay U+F101), so it is terminated with a space.

Source
unquote_text(text : String) : String

text as unquote() hands it out: a single-character escape (\", \', \\, \:) is only an escape inside quotes, so it becomes that character, and an escaped newline is a line continuation. Hex escapes (\f101) stay verbatim: they mean the same code point unquoted (dart-sass prints them back the same).

Source

Instance methods

decoded

The code points the text denotes: \e900 is one character, \" is a quote. text keeps the escapes verbatim so strings pass through byte-identically; string functions and == work on this.

Source
eq?(other : Value) : Bool

Sass equality (==). Subclasses override; default is identity on serialized text.

Source
interp_css

CSS text for this value when it lands inside #{...}. dart-sass renders strings UNQUOTED at every nesting level there, so a list of quoted strings interpolates as a, b — "a", "b" would ship invalid CSS (content: ""a", "b""). Only Str and the containers that hold values override this.

Source
quote_char
Source
quoted
Source
text

Raw text between the quotes, escapes preserved verbatim.

Source
to_css

CSS text for this value (what lands in output).

Source