Rename "render" to "compile"

"Render" is a strange term for compilation that kind of got copied
over from Haml and endured due to inertia.
This commit is contained in:
Natalie Weizenbaum 2017-07-07 17:03:31 -07:00
parent 03315f55f9
commit 970755d82e
7 changed files with 27 additions and 21 deletions

View File

@ -88,7 +88,7 @@ also add it to your pubspec and use it as a library:
import 'package:sass/sass.dart' as sass;
void main(List<String> args) {
print(sass.render(args.first));
print(sass.compile(args.first));
}
```
@ -168,7 +168,7 @@ Sass to update the reference behavior.
`@extend` defined outside that query. This isn't tracked explicitly, because
it'll be irrelevant when [issue 1050][] is fixed.
11. Some selector pseudos containing placeholder selectors will be rendered
11. Some selector pseudos containing placeholder selectors will be compiled
where they wouldn't be in Ruby Sass. This better matches the semantics of
the selectors in question, and is more efficient. See [issue 2228][].

View File

@ -2,11 +2,11 @@
// MIT-style license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.
import 'src/compile.dart' as c;
import 'src/exception.dart';
import 'src/render.dart' as r;
import 'src/sync_package_resolver.dart';
/// Loads the Sass file at [path], converts it to CSS, and returns the result.
/// Loads the Sass file at [path], compiles it to CSS, and returns the result.
///
/// If [color] is `true`, this will use terminal colors in warnings.
///
@ -17,11 +17,11 @@ import 'src/sync_package_resolver.dart';
/// [SyncPackageResolver]: https://www.dartdocs.org/documentation/package_resolver/latest/package_resolver/SyncPackageResolver-class.html
///
/// Throws a [SassException] if conversion fails.
String render(String path,
String compile(String path,
{bool color: false, SyncPackageResolver packageResolver}) =>
r.render(path, color: color, packageResolver: packageResolver);
c.compile(path, color: color, packageResolver: packageResolver);
/// Converts [source] to CSS and returns the result.
/// Compiles [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
@ -37,13 +37,19 @@ String render(String path,
/// be a [String] or a [Uri].
///
/// Throws a [SassException] if conversion fails.
String renderString(String source,
String compileString(String source,
{bool indented: false,
bool color: false,
SyncPackageResolver packageResolver,
url}) =>
r.renderString(source,
c.compileString(source,
indented: indented,
color: color,
packageResolver: packageResolver,
url: url);
/// Use [compile] instead.
@Deprecated('Will be removed in 1.0.0')
String render(String path,
{bool color: false, SyncPackageResolver packageResolver}) =>
c.compile(path, color: color, packageResolver: packageResolver);

View File

@ -27,7 +27,7 @@ export 'selector/universal.dart';
/// Selectors have structural equality semantics.
abstract class Selector {
/// Whether this selector, and complex selectors containing it, should not be
/// rendered.
/// emitted.
bool get isInvisible => false;
/// Calls the appropriate visit method on [visitor].

View File

@ -9,9 +9,9 @@ import 'util/path.dart';
import 'visitor/perform.dart';
import 'visitor/serialize.dart';
/// Like [render] in `lib/sass.dart`, but provides more options to support the
/// Like [compile] in `lib/sass.dart`, but provides more options to support the
/// node-sass compatible API.
String render(String path,
String compile(String path,
{bool indented,
bool color: false,
SyncPackageResolver packageResolver,
@ -20,7 +20,7 @@ String render(String path,
bool useSpaces: true,
int indentWidth,
LineFeed lineFeed}) =>
renderString(readFile(path),
compileString(readFile(path),
indented: indented ?? p.extension(path) == '.sass',
color: color,
packageResolver: packageResolver,
@ -31,9 +31,9 @@ String render(String path,
lineFeed: lineFeed,
url: p.toUri(path));
/// Like [renderString] in `lib/sass.dart`, but provides more options to support
/// Like [compileString] in `lib/sass.dart`, but provides more options to support
/// the node-sass compatible API.
String renderString(String source,
String compileString(String source,
{bool indented: false,
bool color: false,
SyncPackageResolver packageResolver,

View File

@ -47,7 +47,7 @@ main(List<String> args) async {
var color = (options['color'] as bool) ?? hasTerminal;
try {
var css = render(options.rest.first, color: color);
var css = compile(options.rest.first, color: color);
if (css.isNotEmpty) print(css);
} on SassException catch (error, stackTrace) {
stderr.writeln("Error: ${error.message}");

View File

@ -4,6 +4,7 @@
import 'package:js/js.dart';
import 'compile.dart';
import 'exception.dart';
import 'executable.dart' as executable;
import 'node/exports.dart';
@ -11,7 +12,6 @@ import 'node/render_error.dart';
import 'node/render_options.dart';
import 'node/render_result.dart';
import 'node/utils.dart';
import 'render.dart';
import 'visitor/serialize.dart';
/// The entrypoint for Node.js.
@ -78,7 +78,7 @@ RenderResult _doRender(RenderOptions options) {
"options.data and options.file may not both be set.");
}
output = renderString(options.data,
output = compileString(options.data,
loadPaths: options.includePaths,
indented: options.indentedSyntax ?? false,
style: _parseOutputStyle(options.outputStyle),
@ -86,7 +86,7 @@ RenderResult _doRender(RenderOptions options) {
indentWidth: _parseIndentWidth(options.indentWidth),
lineFeed: _parseLineFeed(options.linefeed));
} else if (options.file != null) {
output = render(options.file,
output = compile(options.file,
loadPaths: options.includePaths,
indented: options.indentedSyntax,
style: _parseOutputStyle(options.outputStyle),

View File

@ -20,7 +20,7 @@ main() {
var resolver = new SyncPackageResolver.config(
{"fake_package": p.toUri(p.join(d.sandbox, 'subdir'))});
var css = render(p.join(d.sandbox, "test.scss"), packageResolver: resolver);
var css = compile(p.join(d.sandbox, "test.scss"), packageResolver: resolver);
expect(css, equals("a {\n b: 3;\n}"));
});
@ -30,7 +30,7 @@ main() {
.create();
var resolver = new SyncPackageResolver.config({});
expect(() => render(d.sandbox + "/test.scss", packageResolver: resolver),
expect(() => compile(d.sandbox + "/test.scss", packageResolver: resolver),
throwsA(new isInstanceOf<SassRuntimeException>()));
});
}