platform/packages/jael/jael
Tobe O edfd785dfe Add 'packages/jael/' from commit 'af168281d94cda98a8fd333618696e92f4e035c5'
git-subtree-dir: packages/jael
git-subtree-mainline: 834de0300f
git-subtree-split: af168281d9
2020-02-15 18:22:11 -05:00
..
bin Add 'packages/jael/' from commit 'af168281d94cda98a8fd333618696e92f4e035c5' 2020-02-15 18:22:11 -05:00
example Add 'packages/jael/' from commit 'af168281d94cda98a8fd333618696e92f4e035c5' 2020-02-15 18:22:11 -05:00
lib Add 'packages/jael/' from commit 'af168281d94cda98a8fd333618696e92f4e035c5' 2020-02-15 18:22:11 -05:00
test Add 'packages/jael/' from commit 'af168281d94cda98a8fd333618696e92f4e035c5' 2020-02-15 18:22:11 -05:00
.gitignore Add 'packages/jael/' from commit 'af168281d94cda98a8fd333618696e92f4e035c5' 2020-02-15 18:22:11 -05:00
analysis_options.yaml Add 'packages/jael/' from commit 'af168281d94cda98a8fd333618696e92f4e035c5' 2020-02-15 18:22:11 -05:00
CHANGELOG.md Add 'packages/jael/' from commit 'af168281d94cda98a8fd333618696e92f4e035c5' 2020-02-15 18:22:11 -05:00
LICENSE Add 'packages/jael/' from commit 'af168281d94cda98a8fd333618696e92f4e035c5' 2020-02-15 18:22:11 -05:00
mono_pkg.yaml Add 'packages/jael/' from commit 'af168281d94cda98a8fd333618696e92f4e035c5' 2020-02-15 18:22:11 -05:00
pubspec.yaml Add 'packages/jael/' from commit 'af168281d94cda98a8fd333618696e92f4e035c5' 2020-02-15 18:22:11 -05:00
README.md Add 'packages/jael/' from commit 'af168281d94cda98a8fd333618696e92f4e035c5' 2020-02-15 18:22:11 -05:00

jael

Pub build status

A simple server-side HTML templating engine for Dart.

See documentation.

Installation

In your pubspec.yaml:

dependencies:
  jael: ^2.0.0

API

The core jael package exports classes for parsing Jael templates, an AST library, and a Renderer class that generates HTML on-the-fly.

import 'package:code_buffer/code_buffer.dart';
import 'package:jael/jael.dart' as jael;
import 'package:symbol_table/symbol_table.dart';

void myFunction() {
    const template = '''
<html>
  <body>
    <h1>Hello</h1>
    <img src=profile['avatar']>
  </body>
</html>
''';

    var buf = CodeBuffer();
    var document = jael.parseDocument(template, sourceUrl: 'test.jael', asDSX: false);
    var scope = SymbolTable(values: {
      'profile': {
        'avatar': 'thosakwe.png',
      }
    });

    const jael.Renderer().render(document, buf, scope);
    print(buf);
}

Pre-processing (i.e. handling of blocks and includes) is handled by package:jael_preprocessor..