Socket
Socket
Sign inDemoInstall

edge.js

Package Overview
Dependencies
Maintainers
1
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

edge.js - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

.nyc_output/2c3a9787e5488761930aeb73c042527f.json

10

CHANGELOG.md

@@ -0,1 +1,11 @@

<a name="1.1.0"></a>
# [1.1.0](https://github.com/poppinss/edge/compare/v1.0.2...v1.1.0) (2017-09-23)
### Features
* **tags:** allow multiline tags ([e7783f5](https://github.com/poppinss/edge/commit/e7783f5))
<a name="1.0.2"></a>

@@ -2,0 +12,0 @@ ## [1.0.2](https://github.com/poppinss/edge/compare/v1.0.1...v1.0.2) (2017-08-08)

24

package.json
{
"name": "edge.js",
"version": "1.0.2",
"version": "1.1.0",
"description": "Node.js logical templating engine with fresh air",

@@ -18,23 +18,23 @@ "main": "index.js",

"devDependencies": {
"benchmark": "^2.1.3",
"cheerio": "^0.22.0",
"coveralls": "^2.12.0",
"benchmark": "^2.1.4",
"cheerio": "^1.0.0-rc.2",
"coveralls": "^2.13.1",
"cz-conventional-changelog": "^2.0.0",
"dedent-js": "^1.0.1",
"japa": "^1.0.1",
"japa": "^1.0.4",
"japa-cli": "^1.0.1",
"node-req": "^2.0.1",
"nyc": "^11.0.2",
"semver": "^5.3.0",
"standard": "^10.0.2",
"zombie": "^5.0.5"
"nyc": "^11.2.1",
"semver": "^5.4.1",
"standard": "^10.0.3",
"zombie": "^5.0.7"
},
"dependencies": {
"debug": "^2.6.1",
"debug": "^3.0.1",
"encodeurl": "^1.0.1",
"escape-html": "^1.0.3",
"esprima": "^4.0.0",
"indent-string": "^3.1.0",
"indent-string": "^3.2.0",
"lodash": "^4.17.4",
"node-exceptions": "^2.0.0",
"node-exceptions": "^2.0.2",
"require-uncached": "^1.0.3",

@@ -41,0 +41,0 @@ "upcast": "^1.0.4"

@@ -57,5 +57,80 @@ 'use strict'

this._openedTags = []
this._multilineOpened = null
}
/**
* Process all lines as part of the recently opened
* tag, when tag is multiline
*
* @method _waitUntilTagFinishes
*
* @param {String} line
*
* @return {void}
*
* @private
*/
_waitUntilTagFinishes (line) {
/**
* Remove inline comments from the line
*/
line = line.replace(singleLineComment, '')
/**
* Remove trailing spaces from the line,
* since they have no value
*/
line = line.trim()
/**
* If line is ending with `)`. We will consider
* it the end of the multiline tag
*/
const ending = line.endsWith(')')
/**
* Extract the content from the last
* line, since the line can be
* just `)` or it can be
* the content + `)`
*/
const content = ending ? line.replace(/\)$/, '') : line
/**
* If there was some content next to `args`
* then use append to it, otherwise set
* the first content
*/
this._multilineOpened.args = this._multilineOpened.args
? `${this._multilineOpened.args} ${content}`
: content
/**
* Finally if we are ending, then stop tracking the
* tag and start processing new content
*/
if (ending) {
this._multilineOpened = null
}
}
/**
* Returns a boolean telling if a line has more
* opening braces than closing braces
*
* @method _openingBracesAreMore
*
* @param {String} line
*
* @return {Boolean}
*
* @private
*/
_openingBracesAreMore (line) {
const openingBraces = line.match(/\(/g)
const closingBraces = line.match(/\)/g)
return (openingBraces ? openingBraces.length : 0) > (closingBraces ? closingBraces.length : 0)
}
/**
* Returns the token for a tag.

@@ -78,6 +153,7 @@ *

tag,
args,
args: args ? args.replace(/\)$/, '') : undefined,
selfClosing,
childs: [],
body: line,
multiline: this._openingBracesAreMore(line),
lineno: index + 1,

@@ -230,2 +306,11 @@ end: {

/**
* Wait until the multi line opened tag closes. Till
* then everything will be args for that tag.
*/
if (this._multilineOpened) {
this._waitUntilTagFinishes(line)
return
}
const lastTag = _.last(this._openedTags)

@@ -269,2 +354,10 @@

/**
* Track the opening of multiline tag opening and push all
* upcoming lines as args, unless a closing `)` is found
*/
if (token.tag && token.multiline) {
this._multilineOpened = token
}
/**
* Push to lastTag childs or the actual ast.

@@ -271,0 +364,0 @@ */

@@ -54,3 +54,11 @@ 'use strict'

get allowedExpressions () {
return ['BinaryExpression', 'Literal', 'Identifier', 'CallExpression', 'MemberExpression']
return [
'BinaryExpression',
'Literal',
'Identifier',
'CallExpression',
'MemberExpression',
'UnaryExpression',
'LogicalExpression'
]
}

@@ -57,0 +65,0 @@

@@ -56,3 +56,11 @@ 'use strict'

get allowedExpressions () {
return ['BinaryExpression', 'Literal', 'Identifier', 'CallExpression', 'MemberExpression', 'UnaryExpression']
return [
'BinaryExpression',
'Literal',
'Identifier',
'CallExpression',
'MemberExpression',
'UnaryExpression',
'LogicalExpression'
]
}

@@ -59,0 +67,0 @@

@@ -37,3 +37,3 @@ 'use strict'

this._tags = tags
this._blockRegExp = new RegExp(`^\\s*\\@(!?)(${_.keys(tags).join('|')})(?:\\((.*)\\))?`)
this._blockRegExp = new RegExp(`^\\s*\\@(!?)(${_.keys(tags).join('|')})(?:\\((.*)\\)?)?`)
this._loader = loader

@@ -40,0 +40,0 @@ this.buffer = new InternalBuffer(asFunction)

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