angular_ast 0.4.3

  • README.md
  • CHANGELOG.md
  • Installing
  • Versions
  • 88

angular_ast

Pub
Package

Parser and utilities for AngularDart templates.

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

Usage

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.
  print(tree);

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

Additional flags can be passed to change the behavior of the parser: String sourceUrl: String describing the path of the HTML string. bool desugar: (Default: true) Enabled desugaring of banana-syntax, star syntax, and pipes. bool parseExpressions: (Default: true) Parses Dart expressions raises exceptions if occurred. ExceptionHandler exceptionHandler: (Default: ThrowingExceptionHandler) Switch to 'new RecoveringExceptionHandler()' to enable error recovery.

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( content, sourceUrl: sourceUrl, desugar: false, parseExpressions: false, exceptionHandler: exceptionHandler, ); for (AngularParserException e in exceptionHandler.exceptions) { // Do something with exception. } }

0.4.3

  • Maintenance release, supporting newer package versions.

0.4.2

  • Supports the latest version of quiver.

0.4.1

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.

0.4.0

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.

0.4.0-alpha.1

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

0.4.0-alpha+2

  • 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.

0.4.0-alpha+1

  • New code location! angular_ast is now part of the angular mono-repo on https://github.com/dart-lang/angular.

Bug fix

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

0.2.0

  • 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

0.1.0

  • Initial commit

1. Depend on it

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


dependencies:
  angular_ast: "^0.4.3"

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or packages 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.4.3 Feb 6, 2018 Go to the documentation of angular_ast 0.4.3 Download angular_ast 0.4.3 archive
0.4.2 Jan 18, 2018 Go to the documentation of angular_ast 0.4.2 Download angular_ast 0.4.2 archive
0.4.1 Jan 8, 2018 Go to the documentation of angular_ast 0.4.1 Download angular_ast 0.4.1 archive
0.4.0 Dec 19, 2017 Go to the documentation of angular_ast 0.4.0 Download angular_ast 0.4.0 archive
0.2.0 Jan 10, 2017 Go to the documentation of angular_ast 0.2.0 Download angular_ast 0.2.0 archive
0.4.0-alpha.0 Aug 25, 2017 Go to the documentation of angular_ast 0.4.0-alpha.0 Download angular_ast 0.4.0-alpha.0 archive
0.4.0-alpha+2 Nov 21, 2017 Go to the documentation of angular_ast 0.4.0-alpha+2 Download angular_ast 0.4.0-alpha+2 archive
0.4.0-alpha+1 Oct 10, 2017 Go to the documentation of angular_ast 0.4.0-alpha+1 Download angular_ast 0.4.0-alpha+1 archive
0.1.0-dev Dec 14, 2016 Go to the documentation of angular_ast 0.1.0-dev Download angular_ast 0.1.0-dev archive

Analysis

This feature is new.
We welcome feedback.
More details: scoring.

We analyzed this package, and provided a score, details, and suggestions below.

  • completed on Feb 6, 2018
  • Dart: 2.0.0-dev.20.0
  • pana: 0.10.1

Scores

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

Platforms

Detected platforms: Flutter, other

Primary library: package:angular_ast/angular_ast.dart with components: io.

Suggestions

  • The description is too short.

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

  • Package is pre-v1 release.

    While there is nothing inherently wrong with versions of 0.*.*, it usually means that the author is still experimenting with the general direction API.

  • Maintain an example.

    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.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.20.0 <2.0.0
analyzer ^0.31.0+1 0.31.0+1
charcode ^1.1.0 1.1.1
collection ^1.14.5 1.14.5
meta ^1.1.2 1.1.2
quiver >=0.22.0 <0.29.0 0.28.0
source_span ^1.4.0 1.4.0
string_scanner ^1.0.1 1.0.2
Transitive dependencies
args 1.3.0
async 2.0.3
cli_util 0.1.2+1
convert 2.0.1
crypto 2.0.2+1
csslib 0.14.1
front_end 0.1.0-alpha.8
glob 1.1.5
html 0.13.2+2
isolate 1.1.0
kernel 0.3.0-alpha.5
logging 0.11.3+1
matcher 0.12.1+4
package_config 1.0.3
plugin 0.2.0+2
stack_trace 1.9.1
typed_data 1.1.5
utf 0.9.0+4
watcher 0.9.7+7
yaml 2.1.13
Dev dependencies
path ^1.5.1 1.5.1
test ^0.12.30+1