Stylesheet.parse constructor
Parses a stylesheet from contents
according to syntax
.
If passed, url
is the name of the file from which contents
comes.
Throws a SassFormatException if parsing fails.
Implementation
factory Stylesheet.parse(String contents, Syntax syntax, {Object? url}) {
try {
switch (syntax) {
case Syntax.sass:
return Stylesheet.parseSass(contents, url: url);
case Syntax.scss:
return Stylesheet.parseScss(contents, url: url);
case Syntax.css:
return Stylesheet.parseCss(contents, url: url);
}
} on SassException catch (error, stackTrace) {
var url = error.span.sourceUrl;
if (url == null || url.toString() == 'stdin') rethrow;
throw throwWithTrace(
error.withLoadedUrls(Set.unmodifiable({url})), error, stackTrace);
}
}