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

outdated

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 = new 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 = new CodeBuffer();
      const jael.Renderer().render(
        document,
        output,
        new SymbolTable(values: Platform.environment),
        strictResolution: false,
      );
      print('GENERATED HTML:\n$output');
    }
  }
}
5
likes
0
pub points
1%
popularity

Publisher

verified publisherangel-dart.dev

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

Homepage
Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

charcode, code_buffer, source_span, string_scanner, symbol_table

More

Packages that depend on jael