mirror of
https://github.com/danog/dart-sass.git
synced 2024-12-04 18:47:56 +01:00
Add support for evaluating individual expressions
This commit is contained in:
parent
9939b70ffb
commit
04fc1e46c8
@ -61,6 +61,14 @@ Future<EvaluateResult> evaluateAsync(Stylesheet stylesheet,
|
||||
logger: logger)
|
||||
.run(stylesheet);
|
||||
|
||||
/// Evaluates a single [expression] in [environment]
|
||||
Future<Value> evaluateExpressionAsync(
|
||||
Expression expression, AsyncEnvironment environment) {
|
||||
var evaluator = new _EvaluateVisitor();
|
||||
return evaluator._withEnvironment(
|
||||
environment, () => expression.accept(evaluator));
|
||||
}
|
||||
|
||||
/// A visitor that executes Sass code to produce a CSS tree.
|
||||
class _EvaluateVisitor
|
||||
implements
|
||||
|
@ -5,7 +5,7 @@
|
||||
// DO NOT EDIT. This file was generated from async_evaluate.dart.
|
||||
// See tool/synchronize.dart for details.
|
||||
//
|
||||
// Checksum: 9b5790272f09f8932a01ef9bfa0fd4ebc6b75eaa
|
||||
// Checksum: 4eb54f9170b6c2a337afb7c86502a1a78a0e280f
|
||||
|
||||
import 'dart:math' as math;
|
||||
|
||||
@ -65,6 +65,13 @@ EvaluateResult evaluate(Stylesheet stylesheet,
|
||||
logger: logger)
|
||||
.run(stylesheet);
|
||||
|
||||
/// Evaluates a single [expression] in [environment]
|
||||
Value evaluateExpression(Expression expression, Environment environment) {
|
||||
var evaluator = new _EvaluateVisitor();
|
||||
return evaluator._withEnvironment(
|
||||
environment, () => expression.accept(evaluator));
|
||||
}
|
||||
|
||||
/// A visitor that executes Sass code to produce a CSS tree.
|
||||
class _EvaluateVisitor
|
||||
implements StatementVisitor<Value>, ExpressionVisitor<Value> {
|
||||
|
Loading…
Reference in New Issue
Block a user