Rendering Views

Rendering Views

Just like res.render in Express, Angel's ResponseContext exposes a Future called render. This invokes whichever function is assigned to your server's viewGenerator.

There is a Mustache templating plug-in for Angel available: https://github.com/angel-dart/mustachearrow-up-right

There is also Jaelarrow-up-right, one of the few actively-developed HTML templating engines for Dart.

Angel support for Jael is provided through package:angel_jaelarrow-up-right.

Another is Jinja2, which was recently ported by to Dart by Olzhas Suleimenarrow-up-right.

Angel support for Jinja2 can be found here: https://pub.dartlang.org/packages/angel_jinjaarrow-up-right

Example

app.get('/view', (req, res) async => await res.render('hello', {'locals': ['foo', 'bar']});

ViewGenerator

Angel declares the following typedef:

A templating plug-in can assign one of these to app.viewGenerator to set itself up:

Next Up...

  1. Explore Angel's isomorphic client libraryarrow-up-right.

  2. Find out how to test Angel applications.

Last updated