README, CHANGELOG
This commit is contained in:
parent
b8f2888c7d
commit
f8fd0e0a0a
7 changed files with 92 additions and 14 deletions
1
build_jael/.gitignore
vendored
1
build_jael/.gitignore
vendored
|
@ -13,3 +13,4 @@ pubspec.lock
|
||||||
# If you don't generate documentation locally you can remove this line.
|
# If you don't generate documentation locally you can remove this line.
|
||||||
doc/api/
|
doc/api/
|
||||||
.dart_tool
|
.dart_tool
|
||||||
|
*.html
|
2
build_jael/CHANGELOG.md
Normal file
2
build_jael/CHANGELOG.md
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
# 1.0.0
|
||||||
|
* Initial version.
|
44
build_jael/README.md
Normal file
44
build_jael/README.md
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
# build_jael
|
||||||
|
[![Pub](https://img.shields.io/pub/v/build_jael.svg)](https://pub.dartlang.org/packages/build_jael)
|
||||||
|
[![build status](https://travis-ci.org/angel-dart/jael.svg)](https://travis-ci.org/angel-dart/jael)
|
||||||
|
|
||||||
|
|
||||||
|
Compile Jael files to HTML using the power of `package:build`.
|
||||||
|
|
||||||
|
# Installation
|
||||||
|
In your `pubspec.yaml`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
dependencies:
|
||||||
|
build_jael: ^1.0.0
|
||||||
|
dev_dependencies:
|
||||||
|
build_runner: ^0.7.0
|
||||||
|
```
|
||||||
|
|
||||||
|
# Usage
|
||||||
|
You can run `pub run build_runner serve` to incrementally build Jael templates,
|
||||||
|
and run an HTTP server.
|
||||||
|
|
||||||
|
For further customization, you'll need to either modify the `build.yaml` or
|
||||||
|
instantiate a `JaelBuilder` manually.
|
||||||
|
|
||||||
|
## Defining Variables
|
||||||
|
Pass variables as `config` in `build.yaml`:
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
targets:
|
||||||
|
$default:
|
||||||
|
builders:
|
||||||
|
build_jael:
|
||||||
|
config:
|
||||||
|
foo: bar
|
||||||
|
baz: quux
|
||||||
|
one: 1.0
|
||||||
|
```
|
||||||
|
|
||||||
|
## Minifying HTML
|
||||||
|
Pass `minify: true` in the build configuration to produce "minified" HTML,
|
||||||
|
without newlines or whitespace (other than where it is required).
|
||||||
|
|
||||||
|
To apply additional transforms to parsed documents, provide a
|
||||||
|
set of `patch` functions, like in `package:jael_preprocessor`.
|
|
@ -9,15 +9,10 @@ builders:
|
||||||
.jl:
|
.jl:
|
||||||
- ".html"
|
- ".html"
|
||||||
required_inputs:
|
required_inputs:
|
||||||
- .jl
|
- ".jl"
|
||||||
defaults:
|
|
||||||
generate_for:
|
|
||||||
- "**/*.html"
|
|
||||||
- "*.html"
|
|
||||||
- "**.html"
|
|
||||||
targets:
|
targets:
|
||||||
$default:
|
$default:
|
||||||
sources:
|
sources:
|
||||||
- "**/*.html"
|
- "**.jl"
|
||||||
- "*.html"
|
- "*.jl"
|
||||||
- "**.html"
|
- "**/*.jl"
|
12
build_jael/example/hello.jl
Normal file
12
build_jael/example/hello.jl
Normal file
|
@ -0,0 +1,12 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Hello, world!</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>Hello!</h1>
|
||||||
|
<script>
|
||||||
|
window.alert('Welcome to Jael!');
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -3,12 +3,16 @@ import 'package:build/build.dart';
|
||||||
import 'package:code_buffer/code_buffer.dart';
|
import 'package:code_buffer/code_buffer.dart';
|
||||||
import 'package:file/file.dart';
|
import 'package:file/file.dart';
|
||||||
import 'package:jael/jael.dart' as jael;
|
import 'package:jael/jael.dart' as jael;
|
||||||
import 'package:jael_preprocessor/jael_preprocessor.dart';
|
import 'package:jael_preprocessor/jael_preprocessor.dart' as jael;
|
||||||
|
import 'package:symbol_table/symbol_table.dart';
|
||||||
|
|
||||||
|
Builder jaelBuilder(BuilderOptions options) => new JaelBuilder(options);
|
||||||
|
|
||||||
class JaelBuilder implements Builder {
|
class JaelBuilder implements Builder {
|
||||||
final BuilderOptions options;
|
final BuilderOptions options;
|
||||||
|
final List<jael.Patcher> patch;
|
||||||
|
|
||||||
const JaelBuilder(this.options);
|
const JaelBuilder(this.options, {this.patch: const []});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Map<String, List<String>> get buildExtensions {
|
Map<String, List<String>> get buildExtensions {
|
||||||
|
@ -36,6 +40,24 @@ class JaelBuilder implements Builder {
|
||||||
onError: errors.add,
|
onError: errors.add,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (errors.isNotEmpty) {}
|
doc = await jael.resolve(
|
||||||
|
doc,
|
||||||
|
dir,
|
||||||
|
onError: errors.add,
|
||||||
|
patch: this.patch,
|
||||||
|
);
|
||||||
|
|
||||||
|
if (errors.isNotEmpty) {
|
||||||
|
jael.Renderer.errorDocument(errors, buf);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var scope = new SymbolTable(values: new Map.from(options.config));
|
||||||
|
const jael.Renderer().render(doc, buf, scope);
|
||||||
|
|
||||||
|
buildStep.writeAsString(
|
||||||
|
buildStep.inputId.changeExtension('.html'),
|
||||||
|
buf.toString(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,3 +13,5 @@ dependencies:
|
||||||
jael: ^1.0.0-alpha
|
jael: ^1.0.0-alpha
|
||||||
jael_preprocessor: ^1.0.0-alpha
|
jael_preprocessor: ^1.0.0-alpha
|
||||||
symbol_table: ^1.0.0
|
symbol_table: ^1.0.0
|
||||||
|
dev_dependencies:
|
||||||
|
build_runner: ^0.7.0
|
Loading…
Reference in a new issue