Comparing version 2.0.1 to 2.1.0
@@ -0,1 +1,4 @@ | ||
# 2.1.0 | ||
* Added: exposed `getSnippet()` | ||
# 2.0.1 | ||
@@ -2,0 +5,0 @@ * Fixed: detect and throw syntax error on repeated attributes |
@@ -20,2 +20,3 @@ 'use strict' | ||
module.exports.reduce = require('./lib/reduce') | ||
module.exports.escape = require('./lib/escape') | ||
module.exports.escape = require('./lib/escape') | ||
module.exports.getSnippet = require('./lib/getSnippet') |
@@ -6,2 +6,3 @@ /*jshint evil:true*/ | ||
parse = require('./parse'), | ||
getSnippet = require('./getSnippet'), | ||
reduce | ||
@@ -69,2 +70,3 @@ | ||
var filename = "${escape.js(filename)}" | ||
var getSnippet = ${getSnippet} | ||
${standAloneRenderCode}` | ||
@@ -144,13 +146,3 @@ return new Function('locals, renderCustom', standAloneCode) | ||
} catch (err) { | ||
var lines = source.split('\n'), | ||
fromLine = Math.max(1, line.start - 2) - 1, | ||
toLine = Math.min(lines.length, line.end + 2), | ||
snippet = lines.slice(fromLine, toLine).map(function (str, i) { | ||
var lineNum = i + 1 + fromLine | ||
if (lineNum >= line.start && lineNum <= line.end) { | ||
return ' ' + lineNum + '\t >> | ' + str | ||
} | ||
return ' ' + lineNum + '\t | ' + str | ||
}).join('\n') | ||
var snippet = getSnippet(source, line.start, line.end) | ||
err.path = filename | ||
@@ -157,0 +149,0 @@ err.message = filename + ':' + |
@@ -35,3 +35,4 @@ 'use strict' | ||
voidElementsRegex = /^(area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/, | ||
assert = require('assert') | ||
assert = require('assert'), | ||
getSnippet = require('./getSnippet') | ||
@@ -420,14 +421,5 @@ /** | ||
function throwSyntaxError(message) { | ||
let lines = source.split('\n'), | ||
curr = getSourcePoint(), | ||
fromLine = Math.max(1, curr.line - 2) - 1, | ||
toLine = Math.min(lines.length, curr.line + 2), | ||
snippet = lines.slice(fromLine, toLine).map((line, i) => { | ||
let lineNum = i + 1 + fromLine | ||
if (lineNum === curr.line) { | ||
return ` ${lineNum}\t >> | ${line}` | ||
} | ||
return ` ${lineNum}\t | ${line}` | ||
}).join('\n') | ||
let err = new SyntaxError(`${message}\n${snippet}`) | ||
let curr = getSourcePoint(), | ||
snippet = getSnippet(source, curr.line, curr.line), | ||
err = new SyntaxError(`${message}\n${snippet}`) | ||
err.pos = getSourcePoint() | ||
@@ -434,0 +426,0 @@ throw err |
{ | ||
"name": "ejs-html", | ||
"version": "2.0.1", | ||
"version": "2.1.0", | ||
"author": "Sitegui <sitegui@sitegui.com.br>", | ||
@@ -5,0 +5,0 @@ "description": "Embedded JavaScript HTML templates. Another implementation of EJS, focused on run-time performance, HTML syntax checking and outputting minified HTML.", |
@@ -145,2 +145,5 @@ # EJS HTML | ||
### escape.js(str) | ||
Escape as to make safe to put inside double quotes: `x = "..."` | ||
Escape as to make safe to put inside double quotes: `x = "..."` | ||
### escape.getSnippet(source, lineStart, lineEnd) | ||
Extract the code snippet in the given region (used internally to create error messages) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37913
17
939
148