embla_templates 0.1.4 copy "embla_templates: ^0.1.4" to clipboard
embla_templates: ^0.1.4 copied to clipboard

outdatedDart 1 only

Templating platform for Embla

Templating for Embla #

Usage with Embla #

export 'package:embla/bootstrap.dart';
import 'package:embla/http.dart';

import 'package:embla_templates/embla_templates.dart';
import 'package:embla_templates/engines/html_view_engine.dart';
import 'package:embla_templates/engines/handlebars_view_engine.dart';

get embla => [
  new TemplatingBootstrapper(
    templatesDirectory: 'web',
    engines: [
      HandlebarsViewEngine,
      HtmlViewEngine,
    ]
  ),
  new HttpBootstrapper(
    pipeline: pipe(
      (ViewComposer view) { // Will be responding to each request

        // Given the configuration in the TemplatingBootstrapper,
        // `render` will look for `web/index.hbs` or `web/index.html`
        return view.render('index')
          ..localVariableThatWillBeAvailableInTheTemplate = "value";
      }
    )
  )
];

Usage without Embla #

import 'package:embla_templates/embla_templates.dart';
import 'package:embla_templates/engines/html_view_engine.dart';

import 'package:shelf/shelf.dart' as shelf;

main() async {
  final view = new ViewComposer.create(
    templatesDirectory: 'web',
    engines: [
      new HtmlViewEngine()
    ]
  );

  // Turn index.html into a Template -- a Future Shelf Response
  Template template = view.render('index')
    ..localVariableThatWillBeAvailableInTheTemplate = "value";

  // Future<shelf.Response> is a valid return value in a shelf.Handler
  shelf.Response response = await template;
}
0
likes
15
pub points
0%
popularity

Publisher

unverified uploader

Templating platform for Embla

Repository (GitHub)
View/report issues

License

MIT (LICENSE)

Dependencies

async, embla, mustache, path

More

Packages that depend on embla_templates