jael 2.0.1+2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 71

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

2.0.1

  • Fixed bug where the textarea name check would never return true.

2.0.0+1

  • Meta-update for Pub score.

2.0.0

  • Dart 2 updates.
  • Remove usage of package:dart2_constant.

1.0.6+1

  • Ensure <element> passes attributes.

1.0.6

  • Add index-as to for-each.
  • Support registering + rendering custom elements.
  • Improve handling of booleans in non-strict mode.

1.0.5

  • Add support for DSX, a port of JSX to Dart.

1.0.4

  • Skip HTML comments in free text.

1.0.3

  • Fix a scanner bug that prevented proper parsing of HTML nodes followed by free text.
  • Don't trim <textarea> content.

1.0.2

  • Use package:dart2_constant.
  • Upgrade package:symbol_table.
  • Added Renderer.errorDocument.

1.0.1

  • Reworked the scanner; thereby fixing an extremely pesky bug that prevented successful parsing of Jael files containing JavaScript.

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');
    }
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  jael: ^2.0.1+2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:jael/jael.dart';
  
Version Uploaded Documentation Archive
2.0.1+2 Nov 11, 2018 Go to the documentation of jael 2.0.1+2 Download jael 2.0.1+2 archive
2.0.1+1 Nov 11, 2018 Go to the documentation of jael 2.0.1+1 Download jael 2.0.1+1 archive
2.0.1 Nov 10, 2018 Go to the documentation of jael 2.0.1 Download jael 2.0.1 archive
2.0.0+1 Nov 10, 2018 Go to the documentation of jael 2.0.0+1 Download jael 2.0.0+1 archive
2.0.0 Nov 3, 2018 Go to the documentation of jael 2.0.0 Download jael 2.0.0 archive
1.0.6+1 Jun 28, 2018 Go to the documentation of jael 1.0.6+1 Download jael 1.0.6+1 archive
1.0.6 Jun 28, 2018 Go to the documentation of jael 1.0.6 Download jael 1.0.6 archive
1.0.5 Jun 26, 2018 Go to the documentation of jael 1.0.5 Download jael 1.0.5 archive
1.0.4 Apr 3, 2018 Go to the documentation of jael 1.0.4 Download jael 1.0.4 archive
1.0.3 Apr 3, 2018 Go to the documentation of jael 1.0.3 Download jael 1.0.3 archive

All 23 versions...

Popularity:
Describes how popular the package is relative to other packages. [more]
47
Health:
Code health derived from static analysis. [more]
90
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
71
Learn more about scoring.

We analyzed this package on Dec 5, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.7

Platforms

Detected platforms: web, other

Primary library: package:jael/jael.dart with components: mirrors.

Health issues and suggestions

Document public APIs (-9.88 points)

248 out of 251 API elements (library, class, field or method) have no adequate dartdoc content. Good documentation improves code readability and discoverability through search.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev <=3.0.0
charcode ^1.0.0 1.1.2
code_buffer ^1.0.0 1.0.1
source_span ^1.0.0 1.4.1
string_scanner ^1.0.0 1.0.4
symbol_table ^2.0.0 2.0.0
Transitive dependencies
meta 1.1.6
path 1.6.2
Dev dependencies
test ^1.0.0