platform/jael
2019-07-29 18:12:52 -04:00
..
bin Add dry-run 2019-07-29 18:05:46 -04:00
example Apply pedantic 2019-07-29 18:12:52 -04:00
lib Apply pedantic 2019-07-29 18:12:52 -04:00
test Apply pedantic 2019-07-29 18:12:52 -04:00
.gitignore fixed JS parsing 2018-04-03 01:04:34 -04:00
analysis_options.yaml Add pedantic 2019-07-29 18:07:21 -04:00
CHANGELOG.md Jael formatter + 2.0.2 2019-07-29 18:01:24 -04:00
LICENSE Pre-processor needs work 2017-09-30 01:27:31 -04:00
mono_pkg.yaml Dart 2 update for pkg:jael 2018-11-02 20:16:03 -04:00
pubspec.yaml Add pedantic 2019-07-29 18:07:21 -04:00
README.md Apply pedantic 2019-07-29 18:12:52 -04: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..