angel strict
This commit is contained in:
parent
7c07ad3aa3
commit
4980e81d64
2 changed files with 11 additions and 5 deletions
|
@ -13,7 +13,11 @@ import 'package:symbol_table/symbol_table.dart';
|
||||||
///
|
///
|
||||||
/// To apply additional transforms to parsed documents, provide a set of [patch] functions.
|
/// To apply additional transforms to parsed documents, provide a set of [patch] functions.
|
||||||
AngelConfigurer jael(Directory viewsDirectory,
|
AngelConfigurer jael(Directory viewsDirectory,
|
||||||
{String fileExtension, bool cacheViews: false, Iterable<Patcher> patch, CodeBuffer createBuffer()}) {
|
{String fileExtension,
|
||||||
|
bool strictResolution: false,
|
||||||
|
bool cacheViews: false,
|
||||||
|
Iterable<Patcher> patch,
|
||||||
|
CodeBuffer createBuffer()}) {
|
||||||
var cache = <String, Document>{};
|
var cache = <String, Document>{};
|
||||||
fileExtension ??= '.jl';
|
fileExtension ??= '.jl';
|
||||||
createBuffer ??= () => new CodeBuffer();
|
createBuffer ??= () => new CodeBuffer();
|
||||||
|
@ -29,11 +33,12 @@ AngelConfigurer jael(Directory viewsDirectory,
|
||||||
var file = viewsDirectory.childFile(name + fileExtension);
|
var file = viewsDirectory.childFile(name + fileExtension);
|
||||||
var contents = await file.readAsString();
|
var contents = await file.readAsString();
|
||||||
var doc =
|
var doc =
|
||||||
parseDocument(contents, sourceUrl: file.uri, onError: errors.add);
|
parseDocument(contents, sourceUrl: file.uri, onError: errors.add);
|
||||||
processed = doc;
|
processed = doc;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
processed = await resolve(doc, viewsDirectory, patch: patch, onError: errors.add);
|
processed = await resolve(doc, viewsDirectory,
|
||||||
|
patch: patch, onError: errors.add);
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
// Ignore these errors, so that we can show syntax errors.
|
// Ignore these errors, so that we can show syntax errors.
|
||||||
}
|
}
|
||||||
|
@ -48,7 +53,8 @@ AngelConfigurer jael(Directory viewsDirectory,
|
||||||
|
|
||||||
if (errors.isEmpty) {
|
if (errors.isEmpty) {
|
||||||
try {
|
try {
|
||||||
const Renderer().render(processed, buf, scope);
|
const Renderer().render(processed, buf, scope,
|
||||||
|
strictResolution: strictResolution == true);
|
||||||
return buf.toString();
|
return buf.toString();
|
||||||
} on JaelError catch (e) {
|
} on JaelError catch (e) {
|
||||||
errors.add(e);
|
errors.add(e);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
name: angel_jael
|
name: angel_jael
|
||||||
version: 1.0.0-alpha+1
|
version: 1.0.0-alpha+2
|
||||||
description: Angel support for the Jael templating engine.
|
description: Angel support for the Jael templating engine.
|
||||||
author: Tobe O <thosakwe@gmail.com>
|
author: Tobe O <thosakwe@gmail.com>
|
||||||
homepage: https://github.com/angel-dart/jael/tree/master/jael
|
homepage: https://github.com/angel-dart/jael/tree/master/jael
|
||||||
|
|
Loading…
Reference in a new issue