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 - npm Package Compare versions

Comparing version 0.3.8 to 0.3.9

10

lib/renderer/HTMLRenderer.js

@@ -9,2 +9,5 @@ "use strict";

/**
* The renderer should be able to intersect the propagation?
*/
var HTMLRenderer = {

@@ -37,8 +40,13 @@

ctx.hostname = data.host;
ctx.env = data.env;
try {
env.render(data.template, ctx, function(err, content){
log(err);
// Template not found errors and functional errors -> 500
return callback(err, content, this.type);
}.bind(this));
} catch(error){
// EISDIR, no template was set ... -> 404
// Template, render error (there was a syntax error in the template)
callback(error, null);

@@ -45,0 +53,0 @@ }

36

lib/TemplatingMiddleware.js

@@ -54,3 +54,2 @@ var log = require('ee-log'),

renderer.render(context, function(err, content, type){
// if the renderer created an error send it back to the client

@@ -74,2 +73,3 @@ if(err){

/**
* This is currently a hack! Nunjucks seems to trick us ou!
* todo: simplify this interface!

@@ -88,3 +88,8 @@ * proposal:

// create a context which should be sufficient for all renderers
var context = {content: data, template: template, language:language, host: request.hostname};
var context = {
content: data,
template: template,
language:language,
host: request.hostname
};
// check if the service has overwritten the content type and chose a new renderer

@@ -106,16 +111,25 @@ if(headers['content-type'] && headers['content-type'] !== renderer.type){

// if the renderer created an error send it back to the client
// if the renderer created an error it was not able to handle itself, send it back to the client
if(err){
this.send(500, err.message);
if(err.code == 'EISDIR'){
this.send(404, 'Page not found.');
} else {
this.send(500, err.message);
}
return callback(err);
}
// otherwise set the passed headers and content type
this.setContentType(type+'; charset=utf-8');
this.setHeaders(headers || {});
this.setHeader('content-language', language);
if(!this.isSent){
// otherwise set the passed headers and content type
this.setContentType(type+'; charset=utf-8');
this.setHeaders(headers || {});
this.setHeader('content-language', language);
// and send it back to the client
this.send(status, content);
callback();
// and send it back to the client
this.send(status, content);
callback();
} else {
log.wtf('Tried to send the response twice, this may be caused by a strange behavior of nunjucks.');
log.wtf(context);
}
}.bind(response));

@@ -122,0 +136,0 @@ }.bind(this);

{
"name" : "ee-templates"
, "description" : "Templating integration for the ee-soa-transport-rest based on Nunjucks"
, "version" : "0.3.8"
, "version" : "0.3.9"
, "license" : "MIT"

@@ -6,0 +6,0 @@ , "author" : "Michael Rüfenacht <ruefe@rcky.ch> (http://www.rcky.ch)"

@@ -175,3 +175,3 @@ var assert = require('assert')

var expected = '-<?xmlversion="1.0"encoding="UTF-8"?><root><name><![CDATA[wayne]]></name><firstName><![CDATA[john]]></firstName><age><![CDATA[200]]></age><beatsChuckNorris><![CDATA[true]]></beatsChuckNorris><friends><fullname><![CDATA[chucknorris]]></fullname><id><![CDATA[1]]></id></friends><friends><fullname><![CDATA[captainfuture]]></fullname><id><![CDATA[3]]></id></friends><sexRatio><![CDATA[100.3]]></sexRatio></root>';
var expected = '<?xmlversion="1.0"encoding="UTF-8"?><root><name><![CDATA[wayne]]></name><firstName><![CDATA[john]]></firstName><age><![CDATA[200]]></age><beatsChuckNorris><![CDATA[true]]></beatsChuckNorris><friends><fullname><![CDATA[chucknorris]]></fullname><id><![CDATA[1]]></id></friends><friends><fullname><![CDATA[captainfuture]]></fullname><id><![CDATA[3]]></id></friends><sexRatio><![CDATA[100.3]]></sexRatio></root>';

@@ -178,0 +178,0 @@ it('should create xml', function(done){

Sorry, the diff of this file is not supported yet

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