项目作者: angel-dart-archive

项目描述 :
HAML view generator for Angel.
高级语言: Dart
项目地址: git://github.com/angel-dart-archive/haml.git
创建时间: 2017-03-28T12:17:13Z
项目社区:https://github.com/angel-dart-archive/haml

开源协议:MIT License

下载


haml

under development
build status

HAML view generator for Angel.

Installation

package:angel_haml is actually a source code generator,
and should be a development dependency only.

In your pubspec.yaml:

  1. dev_dependencies:
  2. angel_haml: ^1.0.0
  3. build_runner: ^0.3.0

Usage

To use this codegen, you must include some sort of YAML (or JSON) specification file.
By convention, use views/angel_haml.yaml.

Only include the options you need; the others will be automatically filled with the defaults.

Defaults:

  1. name: hamlViews # Name of generated function
  2. partials: . # Directory to resolve partials from
  3. views: * # List of filenames (no extension) to be compiled, or '*'

Custom example:

  1. partials: ./some/folder/partials
  2. views:
  3. - foo
  4. - bar/baz

Example use with package:build_runner:

  1. import 'package:angel_haml/angel_haml.dart';
  2. import 'package:builder_runner/build_runner.dart';
  3. final PhaseGroup PHASES = new PhaseGroup.singleAction(const AngelHamlBuilder(),
  4. new InputSet('example', const ['views/angel_haml.yaml']));

The generated source file will contain an Angel plug-in that automatically wires
your views for you.

  1. import 'package:angel_common/angel_common.dart';
  2. import 'views/angel_haml.g.dart'; // Generated sources
  3. main() async {
  4. var app = new Angel();
  5. await app.configure(hamlViews()); // Hook up views
  6. // ...
  7. app.get('/', (req, res) => res.render('index')); // Render pre-compiled index.haml
  8. app.get('/invoice/:id', (String id, ResponseContext res) async {
  9. var invoice = await app.service('api/invoices').read(id);
  10. await res.render('invoice_detail', {'invoice': invoice});
  11. // Render pre-compiled invoice_detail.haml
  12. }
  13. }