/pug

[DEPRECATED] Pug (nee Jade) view generator for Angel.

Primary LanguageDartMIT LicenseMIT

DEPRECATED

package:jaded seems to be all but abandoned. Regardless, its approach to templating is far from efficient, and stil doesn't allow for much flexibility in terms of executing code.

Prefer jael, as it is far more expressive, works with Dart 2, and is much faster.

pug

version 1.0.0 build status

Pug (nee Jade) view generator for Angel.

package:jaded currently is broken on Dart 1.0, so this repo is blocked until some fix or alternative library comes out.

Installation

In your pubspec.yaml:

dependencies:
  angel_pug: ^1.0.0

Also, consider adding the following to your .gitignore:

jaded.views.dart

Usage

This package exports a simple Angel plugin that configures your application to render views out of a given directory.

import 'dart:io';
import 'package:angel_framework/angel_framework.dart';
import 'package:angel_pug/angel_pug.dart';

main() async {
  // ...
  await app.configure(pug(new Directory('views')));
}

The pug function accepts an optional Iterable<String> extensions parameter, which defaults to ['.pug', '.jade']. These extensions will be suffixed to template names when calling res.render (i.e. res.render('foo') searches for ['foo.pug', 'foo.jade']) to find the corresponding view file.

If you set it to null or an empty iterable, then extensions will not be added. This is a rare case, and only is necessary if your template files have no extensions.