2016-10-15 03:24:50 +02:00
|
|
|
// Copyright 2016 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.
|
|
|
|
|
2017-02-04 21:20:34 +01:00
|
|
|
import 'src/exception.dart';
|
2017-06-03 00:42:22 +02:00
|
|
|
import 'src/render.dart' as r;
|
2017-02-03 10:08:06 +01:00
|
|
|
import 'src/sync_package_resolver.dart';
|
2016-10-15 03:24:50 +02:00
|
|
|
|
|
|
|
/// Loads the Sass file at [path], converts it to CSS, and returns the result.
|
|
|
|
///
|
2016-10-20 23:35:45 +02:00
|
|
|
/// If [color] is `true`, this will use terminal colors in warnings.
|
|
|
|
///
|
2017-02-03 10:08:06 +01:00
|
|
|
/// If [packageResolver] is provided, it's used to resolve `package:` imports.
|
|
|
|
/// Otherwise, they aren't supported. It takes a [SyncPackageResolver][] from
|
|
|
|
/// the `package_resolver` package.
|
|
|
|
///
|
|
|
|
/// [SyncPackageResolver]: https://www.dartdocs.org/documentation/package_resolver/latest/package_resolver/SyncPackageResolver-class.html
|
|
|
|
///
|
2017-07-07 09:57:10 +02:00
|
|
|
/// Throws a [SassException] if conversion fails.
|
2017-02-03 10:08:06 +01:00
|
|
|
String render(String path,
|
2017-06-03 00:42:22 +02:00
|
|
|
{bool color: false, SyncPackageResolver packageResolver}) =>
|
|
|
|
r.render(path, color: color, packageResolver: packageResolver);
|
2017-07-07 09:57:10 +02:00
|
|
|
|
|
|
|
/// Converts [source] to CSS and returns the result.
|
|
|
|
///
|
|
|
|
/// If [indented] is `true`, this parses [source] using indented syntax;
|
|
|
|
/// otherwise (and by default) it uses SCSS. If [color] is `true`, this will use
|
|
|
|
/// terminal colors in warnings.
|
|
|
|
///
|
|
|
|
/// If [packageResolver] is provided, it's used to resolve `package:` imports.
|
|
|
|
/// Otherwise, they aren't supported. It takes a [SyncPackageResolver][] from
|
|
|
|
/// the `package_resolver` package.
|
|
|
|
///
|
|
|
|
/// [SyncPackageResolver]: https://www.dartdocs.org/documentation/package_resolver/latest/package_resolver/SyncPackageResolver-class.html
|
|
|
|
///
|
|
|
|
/// The [url] indicates the location from which [source] was loaded. It may may
|
|
|
|
/// be a [String] or a [Uri].
|
|
|
|
///
|
|
|
|
/// Throws a [SassException] if conversion fails.
|
|
|
|
String renderString(String source,
|
|
|
|
{bool indented: false,
|
|
|
|
bool color: false,
|
|
|
|
SyncPackageResolver packageResolver,
|
|
|
|
url}) =>
|
|
|
|
r.renderString(source,
|
|
|
|
indented: indented,
|
|
|
|
color: color,
|
|
|
|
packageResolver: packageResolver,
|
|
|
|
url: url);
|