angular_ast 0.5.7

  • Installing
  • Versions
  • 22



Parser and utilities for AngularDart templates.

This package is platform agnostic (no HTML or Dart VM dependencies).


Currently in development and not stable.

import 'package:angular_ast/angular_ast.dart';

main() {
  // Create an AST tree by parsing an AngularDart template.
  var tree = parse('<button [title]="someTitle">Hello</button>');

  // Print to console.

  // Output:
  // [
  //    ElementAst <button> {
  //      properties=
  //        PropertyAst {
  //          title="ExpressionAst {someTitle}"}
  //          childNodes=TextAst {Hello}
  //      }
  //    }
  // ]

Additional flags can be passed to change the behavior of the parser:

Data typeNameDescriptionDefault Value
StringsourceUrlString describing the path of the HTML string.
booldesugarEnabled desugaring of banana-syntax, star syntax, and pipes.true
boolparseExpressionsParses Dart expressions raises exceptions if occurred.true
ExceptionHandlerexceptionHandlerSwitch to 'new RecoveringExceptionHandler()' to enable error recovery.ThrowingExceptionHandler

When using RecoveringExceptionHandler, the accumulated exceptions can be accessed through the RecoveringExceptionHandler object. Refer to the following example:

void parse(String content, String sourceUrl) {
  var exceptionHandler = new RecoveringExceptionHandler();
  var asts = parse(
    sourceUrl: sourceUrl,
    desugar: false,
    parseExpressions: false,
    exceptionHandler: exceptionHandler,
  for (AngularParserException e in exceptionHandler.exceptions) {
    // Do something with exception.


  • Annotations may now have compound names (for example

  • It is now an error to use @deferred on a <template> tag or combined with a structural (i.e. *ngIf) directive.

  • Ignores right-trailing spaces when parsing micro expression let-assignments.

  • When parsing a failed micro expression (i.e. *ngFor), avoids a type error.

  • vellip is now a recognized char.

  • Whitespace inside preformatted text (<pre> tags) is now always preserved.


  • Maintenance release to support Dart 2.0 stable.


  • Maintenance release for -dev.68.


  • Add CloseElementAst complement into ContainerAst.
  • Added support for annotations on <template>.
  • The whitespace transformer now understands @preserveWhitespace.


  • Maintenance release for -dev.60.


  • Maintenance release for -dev.56.


  • Fixed source span range of AttributeAst which would extend past EOF when recovering from a value with an unclosed quote.


  • Exported ParsedAnnotationAst.

  • Added ContainerAst.

  • Annotations may now be assigned values.

  • Added support for annotations on ContainerAst.

  • The * micro-syntax now supports leading whitespace.

  • Whitespace between <ng-content> and </ng-content> will no longer yield a parsing error.


  • The * micro-syntax now supports newlines after an identifier.


  • The minimum SDK version is now sdk: ">=2.0.0-dev.46.0 <2.0.0".

  • The * micro-syntax now supports binding to the primary input when followed by additional input or let bindings. Previously the micro-syntax supported binding to the primary input only in isolation.

    Example usage enabled by this change.


    <template [foo]="expr1" [fooContext]="expr2">


    <div *foo="expr1; context: expr2"></div>


  • BREAKING CHANGE: We no longer support parsing Dart expressions as part of parsing the template AST. We hope to re-add some support for this by migrating the existing parser in package:angular, but we are likely not to have a stable API for some time.

  • BREAKING CHANGE: Deleted ExpressionParserVisitor (related to above).


  • Added MinimizeWhitespaceVisitor.


  • Maintenance release, supporting newer package versions.


  • Maintenance release, supporting newer package versions.


  • Supports the latest version of quiver.


Bug fixes

  • Un-escape HTML characters, such as &lt;, &#8721;, or &#x2211;, when they appear in text. Note, we do not do any un-escaping when these characters appear inside elements.


First stable release in a while! Going forward we'll be versioning this package normally as needed to support the AngularDart template compiler and analyzer plugin.

New features

  • Add RecursiveTemplateAstVisitor, which will visit all AST nodes accessible from the given node.
  • Support ngProjectAs decorator on <ng-content>.

Bug fixes

  • DesugarVisitor now desugars AST nodes which were the (indirect) children of EmbeddedTemplateAst nodes.


  • Update version from 0.4.0-alpha+2 to make it come after 0.4.0-alpha.0 which was published in August 2017.


  • Requires analyzer: ^0.31.0-alpha.1.

New Features

  • Now supports AnnotationAsts, like @deferred.
  • Parse SVG tags as either void or non-void with no error.

Bug fixes

  • Fixed sourceSpan calculation to not include the space before the start of an element decorator.
  • Sets the origin in all synthetic nodes. Previously, we were missing a few cases.
  • Fixed a NPE in DesugarVisitor.


Bug fix

  • Fixed event name for banana syntax [(name)] from nameChanged to nameChange.


  • Add an experimental flag to NgParser (toolFriendlyAstOrigin) which wraps de-sugared AST origins in another synthetic AST that represents the intermediate value (i.e. BananaAst or StarAst)
  • Add support for parsing expressions, including de-sugaring pipes. When parsing templates, expression AST objects automatically use the Dart expression parser.
new ExpressionAst.parse('some + dart + expression')
  • One exception: The | operator is not respected, as it is used for pipes in AngularDart. Instead, this operator is converted into a special PipeExpression.
  • Added TemplateAstVisitor and two examples:
    • HumanizingTemplateAstVisitor
    • IdentityTemplateAstVisitor
  • De-sugars the *ngFor-style micro expressions; see micro/*_test.dart.
    • Added attributes as a valid property of EmbeddedTemplateAst


  • Initial commit

Use this package as a library

1. Depend on it

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

  angular_ast: ^0.5.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:angular_ast/angular_ast.dart';
Version Uploaded Documentation Archive
0.5.7 Oct 10, 2018 Go to the documentation of angular_ast 0.5.7 Download angular_ast 0.5.7 archive
0.5.6 Aug 7, 2018 Go to the documentation of angular_ast 0.5.6 Download angular_ast 0.5.6 archive
0.5.5 Aug 1, 2018 Go to the documentation of angular_ast 0.5.5 Download angular_ast 0.5.5 archive
0.5.4 Jul 16, 2018 Go to the documentation of angular_ast 0.5.4 Download angular_ast 0.5.4 archive
0.5.3+3 Jun 15, 2018 Go to the documentation of angular_ast 0.5.3+3 Download angular_ast 0.5.3+3 archive
0.5.3+2 Jun 5, 2018 Go to the documentation of angular_ast 0.5.3+2 Download angular_ast 0.5.3+2 archive
0.5.3+1 May 24, 2018 Go to the documentation of angular_ast 0.5.3+1 Download angular_ast 0.5.3+1 archive
0.5.3 May 17, 2018 Go to the documentation of angular_ast 0.5.3 Download angular_ast 0.5.3 archive
0.5.2 Apr 23, 2018 Go to the documentation of angular_ast 0.5.2 Download angular_ast 0.5.2 archive
0.5.1 Apr 10, 2018 Go to the documentation of angular_ast 0.5.1 Download angular_ast 0.5.1 archive

All 22 versions...

Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Oct 15, 2018, and provided a score, details, and suggestions below. Analysis was completed with status tool failures using:

  • Dart: 2.0.0
  • pana: 0.12.4


Detected platforms: unsure

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Analysis issues and suggestions

Fix dependencies in pubspec.yaml.

Running pub upgrade failed with the following output:

ERR: The current Dart SDK version is 2.0.0.
 Because angular_ast requires SDK version >=2.1.0-dev.5.0 <3.0.0, version solving failed.

Maintenance issues and suggestions

Fix platform conflicts. (-20 points)

Error(s) prevent platform classification:

Fix dependencies in pubspec.yaml.

Support Dart 2 in pubspec.yaml. (-20 points)

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see

Running dartdoc failed. (-10 points)

Make sure dartdoc runs without any issues.

The description is too short. (-20 points)

Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package. Common file name patterns include: main.dart, example.dart or you could also use angular_ast.dart.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0-dev.5.0 <3.0.0