New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ee-templates

Package Overview
Dependencies
Maintainers
2
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ee-templates

Templating integration for the ee-soa-transport-rest based on Nunjucks

  • 0.3.16
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9
decreased by-60.87%
Maintainers
2
Weekly downloads
 
Created
Source

#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

  • Internet Media Types
  • RFC 2616
  • MDN: Content-Negotiation

##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)

FAQs

Package last updated on 23 Dec 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc