2021-09-13 00:30:02 +00:00
|
|
|
# Jael 3
|
|
|
|
|
2021-09-25 06:32:32 +00:00
|
|
|

|
2021-05-15 09:38:15 +00:00
|
|
|
[](https://dart.dev/null-safety)
|
|
|
|
[](https://gitter.im/angel_dart/discussion)
|
2021-09-25 06:32:32 +00:00
|
|
|
[](https://github.com/dukefirehawk/angel/tree/master/packages/jael/jael/LICENSE)
|
2017-09-29 22:39:37 +00:00
|
|
|
|
|
|
|
A simple server-side HTML templating engine for Dart.
|
|
|
|
|
2021-09-25 06:32:32 +00:00
|
|
|
[See documentation.](https://angel3-docs.dukefirehawk.com/packages/front-end/jael)
|
2017-09-29 22:39:37 +00:00
|
|
|
|
2021-09-13 00:30:02 +00:00
|
|
|
## Installation
|
|
|
|
|
2017-09-29 22:39:37 +00:00
|
|
|
In your `pubspec.yaml`:
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
dependencies:
|
2021-09-25 06:32:32 +00:00
|
|
|
jael3: ^4.2.0
|
2017-09-29 22:39:37 +00:00
|
|
|
```
|
|
|
|
|
2021-09-13 00:30:02 +00:00
|
|
|
## API
|
|
|
|
|
|
|
|
The core `jael3` package exports classes for parsing Jael templates, an AST library, and a `Renderer` class that generates HTML on-the-fly.
|
2017-09-29 22:39:37 +00:00
|
|
|
|
|
|
|
```dart
|
2021-12-30 01:44:26 +00:00
|
|
|
import 'package:belatuk_code_buffer/belatuk_code_buffer.dart';
|
|
|
|
import 'package:belatuk_symbol_table/belatuk_symbol_table.dart';
|
|
|
|
import 'package:jael3/jael3.dart' as jael;
|
2017-09-29 22:39:37 +00:00
|
|
|
|
|
|
|
void myFunction() {
|
|
|
|
const template = '''
|
|
|
|
<html>
|
|
|
|
<body>
|
|
|
|
<h1>Hello</h1>
|
|
|
|
<img src=profile['avatar']>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|
|
''';
|
|
|
|
|
2019-07-29 22:12:52 +00:00
|
|
|
var buf = CodeBuffer();
|
2019-07-29 22:01:24 +00:00
|
|
|
var document = jael.parseDocument(template, sourceUrl: 'test.jael', asDSX: false);
|
2019-07-29 22:12:52 +00:00
|
|
|
var scope = SymbolTable(values: {
|
2017-09-29 22:39:37 +00:00
|
|
|
'profile': {
|
|
|
|
'avatar': 'thosakwe.png',
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
const jael.Renderer().render(document, buf, scope);
|
|
|
|
print(buf);
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
2021-09-25 06:32:32 +00:00
|
|
|
Pre-processing (i.e. handling of blocks and includes) is handled by `package:jael3_preprocessor.`.
|