2017-06-03 00:42:22 +02:00
|
|
|
// Copyright 2017 Google Inc. Use of this source code is governed by an
|
|
|
|
// MIT-style license that can be found in the LICENSE file or at
|
|
|
|
// https://opensource.org/licenses/MIT.
|
|
|
|
|
|
|
|
import 'ast/sass.dart';
|
|
|
|
import 'io.dart';
|
|
|
|
import 'sync_package_resolver.dart';
|
2017-07-07 04:29:39 +02:00
|
|
|
import 'util/path.dart';
|
2017-06-03 00:42:22 +02:00
|
|
|
import 'visitor/perform.dart';
|
|
|
|
import 'visitor/serialize.dart';
|
|
|
|
|
|
|
|
/// Like [render] in `lib/sass.dart`, but provides more options to support the
|
|
|
|
/// node-sass compatible API.
|
|
|
|
String render(String path,
|
2017-07-07 09:57:10 +02:00
|
|
|
{bool color: false,
|
|
|
|
SyncPackageResolver packageResolver,
|
|
|
|
bool useSpaces: true,
|
|
|
|
int indentWidth,
|
|
|
|
LineFeed lineFeed}) =>
|
|
|
|
renderString(readFile(path),
|
|
|
|
indented: p.extension(path) == '.sass',
|
|
|
|
color: color,
|
|
|
|
packageResolver: packageResolver,
|
|
|
|
useSpaces: useSpaces,
|
|
|
|
indentWidth: indentWidth,
|
|
|
|
lineFeed: lineFeed,
|
|
|
|
url: p.toUri(path));
|
|
|
|
|
|
|
|
/// Like [renderString] in `lib/sass.dart`, but provides more options to support
|
|
|
|
/// the node-sass compatible API.
|
|
|
|
String renderString(String source,
|
|
|
|
{bool indented: false,
|
|
|
|
bool color: false,
|
2017-06-03 00:42:22 +02:00
|
|
|
SyncPackageResolver packageResolver,
|
|
|
|
bool useSpaces: true,
|
2017-06-16 00:19:26 +02:00
|
|
|
int indentWidth,
|
2017-07-07 09:57:10 +02:00
|
|
|
LineFeed lineFeed,
|
|
|
|
url}) {
|
|
|
|
var sassTree = indented
|
|
|
|
? new Stylesheet.parseSass(source, url: url, color: color)
|
|
|
|
: new Stylesheet.parseScss(source, url: url, color: color);
|
2017-06-03 00:42:22 +02:00
|
|
|
var cssTree =
|
|
|
|
evaluate(sassTree, color: color, packageResolver: packageResolver);
|
2017-06-16 00:19:26 +02:00
|
|
|
return toCss(cssTree,
|
|
|
|
useSpaces: useSpaces, indentWidth: indentWidth, lineFeed: lineFeed);
|
2017-06-03 00:42:22 +02:00
|
|
|
}
|