jinja 0.0.7

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

Pub Build Status

Jinja 2 server-side template engine for Dart 2. Variables, expressions, control structures and template inheritance. #

Draft

All variables passed to the template and literals used in the template are dart objects with their own fields and methods.

To Do #

  • Compile templates to fast Dart code
  • Docs
  • Informative error handling
  • Package tests
  • Add missing filters
  • Loaders
    • PackageLoader
    • FunctionLoader
    • PrefixLoader
    • ChoiceLoader
  • Whitespace Control
  • Escaping
  • Line Statements
  • Statements
    • For
      • Recursive
    • Macro
    • Call
    • Filter
    • Set
    • Template Inheritance
      • Include
      • Import
  • Expressions
    • ... if ... else ... condition expression
    • ~ concat

Done #

  • Loaders
    • FileSystemLoader
    • MapLoader (DictLoader)
  • Variables
  • Filters
    • abs
    • attr
    • batch
    • default
    • e,escape
    • join
    • list
    • lower
    • sublist
    • sum
  • Tests
  • Comments
  • Statements
    • For
    • If
    • Template Inheritance
      • Extends
      • Block
        • Super
  • Expressions
    • Literals
    • Math
    • Comparison
    • Logic
    • in
    • is tests
    • | filters
    • () call callable
    • ./[] object attribute (. for field, [] for map)

0.0.7 #

  • Add global namespace to env and update context
  • Add all missing builtin tests
  • Fix expression group parsing
  • Update package tests
  • Formatting & fixes

0.0.6 #

  • Add undefined & env.finalize
  • Add and switch to env call template, filter, test methods
  • Add is and in expressions
  • Add sum filter
  • Formatting & fixes

0.0.5 #

  • Add batch and escape filters
  • Template and context required env
  • Environment fromSource can store template
  • Formatting & fixes

0.0.4 #

  • Add test for for-loop & if-condition
  • Add defined filter
  • Immutable context
  • Little Docs
  • Formatting & fixes

0.0.3 #

  • Fixes & formatting
  • More filters & tests, package tests

0.0.2 #

  • Fixes & formatting

0.0.1 #

  • Base statements, variables, inheritance, filters & tests and example

example/README.md

Simple shelf server with Jinja 2 example

Example usage #

import 'package:jinja/jinja.dart';

void main() {
  const source = '{% for user in users %}'
      '{{ user["fullname"] }}, {{ user["email"] }};'
      '{% else %}No users{% endfor %}';

  var env = Environment();
  var template = env.fromSource(source, path: 'index.html');

  print(template.render(<String, dynamic>{
    'users': <dynamic>[
      {'fullname': 'Jhon Doe', 'email': 'jhondoe@unknown.dev'},
      {'fullname': 'Jane Doe', 'email': 'janedoe@unknown.dev'},
    ]
  }));
}

Use this package as a library

1. Depend on it

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


dependencies:
  jinja: ^0.0.7

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:jinja/jinja.dart';
  
Version Uploaded Documentation Archive
0.0.7 Feb 4, 2019 Go to the documentation of jinja 0.0.7 Download jinja 0.0.7 archive
0.0.6 Feb 3, 2019 Go to the documentation of jinja 0.0.6 Download jinja 0.0.6 archive
0.0.5 Feb 2, 2019 Go to the documentation of jinja 0.0.5 Download jinja 0.0.5 archive
0.0.4 Jan 28, 2019 Go to the documentation of jinja 0.0.4 Download jinja 0.0.4 archive
0.0.2 Jan 17, 2019 Go to the documentation of jinja 0.0.2 Download jinja 0.0.2 archive
0.0.1 Jan 17, 2019 Go to the documentation of jinja 0.0.1 Download jinja 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
15
Health:
Code health derived from static analysis. [more]
98
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
55
Learn more about scoring.

We analyzed this package on Feb 14, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.1.0
  • pana: 0.12.13

Platforms

Detected platforms: other

Primary library: package:jinja/jinja.dart with components: io, mirrors.

Health suggestions

Fix lib/src/context.dart. (-1.99 points)

Analysis of lib/src/context.dart reported 4 hints:

line 12 col 17: Use = to separate a named parameter from its default value.

line 13 col 18: Use = to separate a named parameter from its default value.

line 15 col 33: Use = to separate a named parameter from its default value.

line 16 col 18: Use = to separate a named parameter from its default value.

Fix lib/jinja.dart. (-0.50 points)

Analysis of lib/jinja.dart reported 1 hint:

line 6 col 30: The library 'package:jinja/src/nodes.dart' doesn't export a member with the shown name 'Undefined'.

Format lib/src/loaders.dart.

Run dartfmt to format lib/src/loaders.dart.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
path ^1.6.2 1.6.2
string_scanner ^1.0.4 1.0.4
Transitive dependencies
charcode 1.1.2
meta 1.1.7
source_span 1.5.4
term_glyph 1.1.0
Dev dependencies
test ^1.5.3