platform/jael
2017-10-02 13:29:02 -04:00
..
lib updated example 2017-10-02 13:29:02 -04:00
test updated example 2017-10-02 13:29:02 -04:00
.gitignore core nearly done 2017-09-29 18:39:37 -04:00
analysis_options.yaml core nearly done 2017-09-29 18:39:37 -04:00
LICENSE Pre-processor needs work 2017-09-30 01:27:31 -04:00
pubspec.yaml updated example 2017-10-02 13:29:02 -04:00
README.md updated example 2017-10-02 13:29:02 -04:00

jael

Pub build status

A simple server-side HTML templating engine for Dart.

See documentation.

Installation

In your pubspec.yaml:

dependencies:
  jael: ^1.0.0-beta

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 = new CodeBuffer();
    var document = jael.parseDocument(template, sourceUrl: 'test.jl');
    var scope = new 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..