ee-templates
Templating integration for the ee-soa-transport-rest based on Nunjucks
Last updated 6 years ago by ee .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install ee-templates 
SYNC missed versions from official npm registry.

#EE-Templates Templating integration for Nunjucks (Middleware)

##Middleware The middleware can be hooked into the application stack and will append a render(status, headers, data, callback) method to the original http response (or any kind of response which adheres to the interface defined for response in ee-webserver). The renderer method contains a renderer resolved based on the accept headers, which renders the passed content into an appropriate representation for the http protocol (properly supperted at the moment: text/html or application/json).

##Renderers Currently there are only two supported renderers: HTML and JSON. The environments (nunjucks) are application specific and need to be passed to the middleware.

###HTMLRenderer The HTMLRenderer is a wrapper for nunjucks. It creates a new environment based on the domain of the request and loads the template which has to be set on the request (in our case resolved by the rewriting middleware).

###DefaultRenderer The DefaultRenderer uses JSON.stringify and converts the passed data to a string.

##Templating Extensions The templating extensions originally provided by this package were moved to their own packages ee-soa-extension-api and ee-soa-extension-locale. Since environments now are passed into the middleware, the dependency is removed and extensions are directly attached by the running application.

##Todo

  • Add a better loader which allows loading the templates asynchronously
  • Improve handling of the mapping between the accept header and the renderer.

##Media Types Further readings

##Changelog

v0.2.0

  • the render method of the response now directly writes the data back to the original response
  • the renderers now directly write their assigned content type to the response
  • the renderers directly create server errors if the rendering created an error
  • therefore the API has slightly changed from render(data, callback) to render(status, headers, data, callback)

Current Tags

  • 0.4.14                                ...           latest (5 years ago)

35 Versions

  • 0.4.14                                ...           5 years ago
  • 0.4.13                                ...           5 years ago
  • 0.4.12                                ...           5 years ago
  • 0.4.11                                ...           5 years ago
  • 0.4.10                                ...           5 years ago
  • 0.4.9                                ...           5 years ago
  • 0.4.8                                ...           5 years ago
  • 0.4.7                                ...           5 years ago
  • 0.4.6                                ...           5 years ago
  • 0.4.5                                ...           5 years ago
  • 0.4.4                                ...           5 years ago
  • 0.4.3                                ...           5 years ago
  • 0.4.2                                ...           6 years ago
  • 0.4.1                                ...           6 years ago
  • 0.4.0                                ...           6 years ago
  • 0.3.16                                ...           6 years ago
  • 0.3.15                                ...           6 years ago
  • 0.3.14                                ...           6 years ago
  • 0.3.13                                ...           6 years ago
  • 0.3.12                                ...           6 years ago
  • 0.3.11                                ...           6 years ago
  • 0.3.10                                ...           6 years ago
  • 0.3.9                                ...           6 years ago
  • 0.3.8                                ...           6 years ago
  • 0.3.7                                ...           6 years ago
  • 0.3.6                                ...           6 years ago
  • 0.3.5                                ...           6 years ago
  • 0.3.4                                ...           6 years ago
  • 0.3.3                                ...           6 years ago
  • 0.3.2                                ...           6 years ago
  • 0.3.1                                ...           6 years ago
  • 0.3.0                                ...           6 years ago
  • 0.2.1                                ...           6 years ago
  • 0.2.0                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
Maintainers (2)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (2)
Dependents (1)

Copyright 2014 - 2016 © taobao.org |