jael 2.0.2 copy "jael: ^2.0.2" to clipboard
jael: ^2.0.2 copied to clipboard

A simple server-side HTML templating engine for Dart. Comparable to Blade or Liquid.

example/main.dart

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

main() {
  while (true) {
    var buf = StringBuffer();
    int ch;
    print('Enter lines of Jael text, terminated by CTRL^D.');
    print('All environment variables are injected into the template scope.');

    while ((ch = stdin.readByteSync()) != $eot && ch != -1) {
      buf.writeCharCode(ch);
    }

    var document = jael.parseDocument(
      buf.toString(),
      sourceUrl: 'stdin',
      onError: stderr.writeln,
    );

    if (document == null) {
      stderr.writeln('Could not parse the given text.');
    } else {
      var output = CodeBuffer();
      const jael.Renderer().render(
        document,
        output,
        SymbolTable(values: Platform.environment),
        strictResolution: false,
      );
      print('GENERATED HTML:\n$output');
    }
  }
}
5
likes
40
pub points
0%
popularity

Publisher

verified publisherangel-dart.dev

A simple server-side HTML templating engine for Dart. Comparable to Blade or Liquid.

Homepage

License

MIT (license)

Dependencies

args, charcode, code_buffer, source_span, string_scanner, symbol_table

More

Packages that depend on jael