Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

ejs

Package Overview
Dependencies
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ejs - npm Package Compare versions

Comparing version 0.4.3 to 0.5.0

8

History.md
0.5.0 / 2011-11-20
==================
* Added express 3.x support
* Added ejs.renderFile()
* Added 'json' filter
* Fixed tests for 0.5.x
0.4.3 / 2011-06-20

@@ -3,0 +11,0 @@ ==================

52

lib/ejs.js

@@ -18,3 +18,3 @@

exports.version = '0.4.3';
exports.version = '0.5.0';

@@ -126,3 +126,3 @@ /**

var prefix, postfix, line = '__stack.lineno=' + lineno;
switch (str[i]) {
switch (str.substr(i, 1)) {
case '=':

@@ -149,17 +149,17 @@ prefix = "', escape((" + line + ', ';

while (~(n = js.indexOf("\n", n))) n++, lineno++;
if (js[0] == ':') js = filtered(js);
if (js.substr(0, 1) == ':') js = filtered(js);
buf.push(prefix, js, postfix);
i += end - start + close.length - 1;
} else if (str[i] == "\\") {
} else if (str.substr(i, 1) == "\\") {
buf.push("\\\\");
} else if (str[i] == "'") {
} else if (str.substr(i, 1) == "'") {
buf.push("\\'");
} else if (str[i] == "\r") {
} else if (str.substr(i, 1) == "\r") {
buf.push(" ");
} else if (str[i] == "\n") {
} else if (str.substr(i, 1) == "\n") {
buf.push("\\n");
lineno++;
} else {
buf.push(str[i]);
buf.push(str.substr(i, 1));
}

@@ -242,2 +242,36 @@ }

/**
* Render an EJS file at the given `path` and callback `fn(err, str)`.
*
* @param {String} path
* @param {Object|Function} options or callback
* @param {Function} fn
* @api public
*/
exports.renderFile = function(path, options, fn){
var key = path + ':string';
if ('function' == typeof options) {
fn = options, options = {};
}
options.filename = path;
try {
var str = options.cache
? exports.cache[key] || (exports.cache[key] = fs.readFileSync(path, 'utf8'))
: fs.readFileSync(path, 'utf8');
options.locals = options;
fn(null, exports.render(str, options));
} catch (err) {
fn(err);
}
};
// express support
exports.__express = exports.renderFile;
/**
* Expose to require().

@@ -250,3 +284,3 @@ */

module._compile(compile(source, {}), filename);
};
};
} else if (require.registerExtension) {

@@ -253,0 +287,0 @@ require.registerExtension('.ejs', function(src) {

5

package.json
{
"name": "ejs",
"description": "Embedded JavaScript templates",
"version": "0.4.3",
"version": "0.5.0",
"author": "TJ Holowaychuk <tj@vision-media.ca>",
"keywords": ["template", "engine", "ejs"],
"devDependencies": {
"expresso": "0.9.2"
},
"main": "./lib/ejs.js"
}

@@ -45,3 +45,3 @@

## Custom Tags
## Custom tags

@@ -89,3 +89,3 @@ Custom tags can also be applied globally:

## Filter List
## Filter list

@@ -117,2 +117,12 @@ Currently these filters are available:

## Adding filters
To add a filter simply add a method to the `.filters` object:
```js
ejs.filters.last = function(obj) {
return obj[obj.length - 1];
};
```
## client-side support

@@ -119,0 +129,0 @@

@@ -150,3 +150,3 @@

return function(p){
if ('.' != p[0]) return require(p);
if ('.' != p.substr(0, 1)) return require(p);

@@ -153,0 +153,0 @@ var path = parent.split('/')

@@ -6,14 +6,15 @@

var ejs = require('ejs');
var ejs = require('../')
, assert = require('assert');
module.exports = {
'test .version': function(assert){
'test .version': function(){
assert.ok(/^\d+\.\d+\.\d+$/.test(ejs.version), 'Test .version format');
},
'test html': function(assert){
'test html': function(){
assert.equal('<p>yay</p>', ejs.render('<p>yay</p>'));
},
'test buffered code': function(assert){
'test buffered code': function(){
var html = '<p>tj</p>',

@@ -25,3 +26,3 @@ str = '<p><%= name %></p>',

'test unbuffered code': function(assert){
'test unbuffered code': function(){
var html = '<p>tj</p>',

@@ -33,3 +34,3 @@ str = '<% if (name) { %><p><%= name %></p><% } %>',

'test `scope` option': function(assert){
'test `scope` option': function(){
var html = '<p>tj</p>',

@@ -40,3 +41,3 @@ str = '<p><%= this %></p>';

'test escaping': function(assert){
'test escaping': function(){
assert.equal('&lt;script&gt;', ejs.render('<%= "<script>" %>'));

@@ -46,3 +47,3 @@ assert.equal('<script>', ejs.render('<%- "<script>" %>'));

'test newlines': function(assert){
'test newlines': function(){
var html = '\n<p>tj</p>\n<p>tj@sencha.com</p>',

@@ -54,3 +55,3 @@ str = '<% if (name) { %>\n<p><%= name %></p>\n<p><%= email %></p><% } %>',

'test single quotes': function(assert){
'test single quotes': function(){
var html = '<p>WAHOO</p>',

@@ -62,3 +63,3 @@ str = "<p><%= up('wahoo') %></p>",

'test single quotes in the html': function(assert){
'test single quotes in the html': function(){
var html = '<p>WAHOO that\'s cool</p>',

@@ -70,3 +71,3 @@ str = '<p><%= up(\'wahoo\') %> that\'s cool</p>',

'test multiple single quotes': function(assert) {
'test multiple single quotes': function() {
var html = "<p>couldn't shouldn't can't</p>",

@@ -77,3 +78,3 @@ str = "<p>couldn't shouldn't can't</p>";

'test single quotes inside tags': function(assert) {
'test single quotes inside tags': function() {
var html = '<p>string</p>',

@@ -84,3 +85,3 @@ str = "<p><%= 'string' %></p>";

'test back-slashes in the document': function(assert) {
'test back-slashes in the document': function() {
var html = "<p>backslash: '\\'</p>",

@@ -91,3 +92,3 @@ str = "<p>backslash: '\\'</p>";

'test double quotes': function(assert){
'test double quotes': function(){
var html = '<p>WAHOO</p>',

@@ -99,3 +100,3 @@ str = '<p><%= up("wahoo") %></p>',

'test multiple double quotes': function(assert) {
'test multiple double quotes': function() {
var html = '<p>just a "test" wahoo</p>',

@@ -106,3 +107,3 @@ str = '<p>just a "test" wahoo</p>';

'test whitespace': function(assert){
'test whitespace': function(){
var html = '<p>foo</p>',

@@ -117,3 +118,3 @@ str = '<p><%="foo"%></p>';

'test custom tags': function(assert){
'test custom tags': function(){
var html = '<p>foo</p>',

@@ -136,3 +137,3 @@ str = '<p>{{= "foo" }}</p>';

'test custom tags over 2 chars': function(assert){
'test custom tags over 2 chars': function(){
var html = '<p>foo</p>',

@@ -155,3 +156,3 @@ str = '<p>{{{{= "foo" }>>}</p>';

'test global custom tags': function(assert){
'test global custom tags': function(){
var html = '<p>foo</p>',

@@ -166,3 +167,3 @@ str = '<p>{{= "foo" }}</p>';

'test iteration': function(assert){
'test iteration': function(){
var html = '<p>foo</p>',

@@ -189,3 +190,3 @@ str = '<% for (var key in items) { %>'

'test filter support': function(assert){
'test filter support': function(){
var html = 'Zab',

@@ -200,3 +201,3 @@ str = '<%=: items | reverse | first | reverse | capitalize %>';

'test filter argument support': function(assert){
'test filter argument support': function(){
var html = 'tj, guillermo',

@@ -214,3 +215,3 @@ str = '<%=: users | map:"name" | join:", " %>';

'test sort_by filter': function(assert){
'test sort_by filter': function(){
var html = 'tj',

@@ -229,3 +230,3 @@ str = '<%=: users | sort_by:"name" | last | get:"name" %>';

'test custom filters': function(assert){
'test custom filters': function(){
var html = 'Welcome Tj Holowaychuk',

@@ -247,3 +248,3 @@ str = '<%=: users | first | greeting %>';

'test useful stack traces': function(assert){
'test useful stack traces': function(){
var str = [

@@ -268,3 +269,3 @@ "A little somethin'",

'test useful stack traces multiline': function(assert){
'test useful stack traces multiline': function(){
var str = [

@@ -271,0 +272,0 @@ "A little somethin'",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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