Fix newlines in interpolation. (#73)

This commit is contained in:
Natalie Weizenbaum 2016-12-18 22:19:50 -08:00 committed by GitHub
parent b4730dd6a6
commit 9fdc8194fd
2 changed files with 15 additions and 2 deletions

View File

@ -11,6 +11,8 @@
* `str-slice()` now correctly returns `""` when `$end-at` is negative and points
before the beginning of the string.
* Interpolation in quoted strings now properly preserves newlines.
* Don't crash when passing only `$hue` or no keyword arguments to
`adjust-color()`, `scale-color()`, or `change-color()`.

View File

@ -1293,8 +1293,19 @@ class _PerformVisitor
return selector.value.asSassList;
}
SassString visitStringExpression(StringExpression node) =>
new SassString(_performInterpolation(node.text), quotes: node.hasQuotes);
SassString visitStringExpression(StringExpression node) {
// Don't use [performInterpolation] here because we need to get the raw text
// from strings.
return new SassString(
node.text.contents.map((value) {
if (value is String) return value;
var result = (value as Expression).accept(this);
return result is SassString
? result.text
: result.toCssString(quote: false);
}).join(),
quotes: node.hasQuotes);
}
// ## Utilities