diff --git a/build_jael/.gitignore b/build_jael/.gitignore new file mode 100644 index 00000000..9afb070e --- /dev/null +++ b/build_jael/.gitignore @@ -0,0 +1,15 @@ +# Created by .ignore support plugin (hsz.mobi) +### Dart template +# See https://www.dartlang.org/tools/private-files.html + +# Files and directories created by pub +.packages +.pub/ +build/ +# If you're building an application, you may want to check-in your pubspec.lock +pubspec.lock + +# Directory created by dartdoc +# If you don't generate documentation locally you can remove this line. +doc/api/ +.dart_tool \ No newline at end of file diff --git a/build_jael/build.yaml b/build_jael/build.yaml new file mode 100644 index 00000000..14c0a3d1 --- /dev/null +++ b/build_jael/build.yaml @@ -0,0 +1,23 @@ +builders: + jael: + target: "build_jael" + import: "package:build_jael/build_jael.dart" + builder_factories: + - jaelBuilder + auto_apply: root_package + build_extensions: + .jl: + - ".html" + required_inputs: + - .jl + defaults: + generate_for: + - "**/*.html" + - "*.html" + - "**.html" +targets: + $default: + sources: + - "**/*.html" + - "*.html" + - "**.html" \ No newline at end of file diff --git a/build_jael/lib/build_jael.dart b/build_jael/lib/build_jael.dart new file mode 100644 index 00000000..e9f5ebf9 --- /dev/null +++ b/build_jael/lib/build_jael.dart @@ -0,0 +1,41 @@ +import 'dart:async'; +import 'package:build/build.dart'; +import 'package:code_buffer/code_buffer.dart'; +import 'package:file/file.dart'; +import 'package:jael/jael.dart' as jael; +import 'package:jael_preprocessor/jael_preprocessor.dart'; + +class JaelBuilder implements Builder { + final BuilderOptions options; + + const JaelBuilder(this.options); + + @override + Map> get buildExtensions { + return { + '.jl': ['.html'], + }; + } + + @override + Future build(BuildStep buildStep) async { + CodeBuffer buf; + + if (options.config['minify'] == true) + buf = new CodeBuffer(space: '', newline: '', trailingNewline: false); + else + buf = new CodeBuffer(); + + Directory dir; + + var errors = []; + + var doc = await jael.parseDocument( + await buildStep.readAsString(buildStep.inputId), + sourceUrl: buildStep.inputId.uri, + onError: errors.add, + ); + + if (errors.isNotEmpty) {} + } +} diff --git a/build_jael/pubspec.yaml b/build_jael/pubspec.yaml new file mode 100644 index 00000000..fc73ef43 --- /dev/null +++ b/build_jael/pubspec.yaml @@ -0,0 +1,15 @@ +name: build_jael +version: 1.0.0 +description: Compile Jael files to HTML using the power of `package:build`. +author: Tobe O +homepage: https://github.com/angel-dart/jael/tree/master/build_jael +environment: + sdk: ">=1.19.0 <=2.0.0" +dependencies: + build: ^0.12.0 + build_config: ^0.2.0 + code_buffer: ^1.0.0 + file: ^2.0.0 + jael: ^1.0.0-alpha + jael_preprocessor: ^1.0.0-alpha + symbol_table: ^1.0.0 \ No newline at end of file