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

pure-engine

Package Overview
Dependencies
Maintainers
1
Versions
68
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pure-engine - npm Package Compare versions

Comparing version 0.11.15 to 0.11.16

src/tags/space.js

4

package.json
{
"name": "pure-engine",
"version": "0.11.15",
"version": "0.11.16",
"description": "Compile HTML templates into JS",

@@ -54,3 +54,3 @@ "main": "index.js",

"dependencies": {
"abstract-syntax-tree": "^2.0.1",
"abstract-syntax-tree": "^2.4.0",
"astoptech": "^1.0.6",

@@ -57,0 +57,0 @@ "asttv": "^1.0.1",

@@ -121,2 +121,6 @@ # pure-engine

</for>
<for key and value in car>
{key}{value}
</for>
```

@@ -123,0 +127,0 @@

@@ -28,2 +28,3 @@ const AbstractSyntaxTree = require('abstract-syntax-tree')

const spacingTag = require('./tags/spacing')
const spaceTag = require('./tags/space')
const { getCondition } = require('./conditions')

@@ -756,2 +757,4 @@ const normalizeNewline = require('normalize-newline')

spacingTag({ fragment, tree, options })
} else if (tag === 'space') {
spaceTag({ tree, attrs })
}

@@ -758,0 +761,0 @@ depth -= 1

@@ -74,3 +74,4 @@ module.exports = {

'font',
'spacing'
'spacing',
'space'
],

@@ -77,0 +78,0 @@ UNESCAPED_NAMES: [

@@ -6,3 +6,4 @@ const {

} = require('./enum')
const { replace } = require('abstract-syntax-tree')
const { replace, generate } = require('abstract-syntax-tree')
const AbstractSyntaxTree = require('abstract-syntax-tree')
const { getIdentifier, getLiteral } = require('./ast')

@@ -33,2 +34,21 @@

function getNestedObjectMemberExpression (node) {
const code = `${OBJECT_VARIABLE}.${generate(node)}`
const tree = new AbstractSyntaxTree(code)
const memberExpression = tree.first('MemberExpression')
replace(memberExpression, {
enter: node => {
if (node.computed && node.type === 'MemberExpression') {
if (node.property.type === 'Identifier') {
node.property = getObjectMemberExpression(node.property.name)
} else if (node.property.type === 'MemberExpression') {
node.property = getNestedObjectMemberExpression(node.property)
}
}
return node
}
})
return memberExpression
}
function getEscapeCallExpression (node) {

@@ -65,2 +85,4 @@ return {

return start
} else if (start.type === 'MemberExpression') {
return getNestedObjectMemberExpression(start)
} else {

@@ -83,2 +105,4 @@ replaceIdentifierWithObjectMemberExpression(start)

return end
} else if (end.type === 'MemberExpression') {
return getNestedObjectMemberExpression(end)
} else {

@@ -85,0 +109,0 @@ replaceIdentifierWithObjectMemberExpression(end)

const AbstractSyntaxTree = require('abstract-syntax-tree')
const utilities = require('pure-utilities')
const { CompilerError } = require('./errors')
const { getObjectMemberExpression } = require('./factory')
const { wrap } = require('pure-utilities/string')

@@ -28,2 +30,3 @@ const aliases = {

const index = languages.indexOf(language)
if (!translations[key] || !translations[key][index]) return ''
return translations[key][index]

@@ -47,3 +50,12 @@ }

type: 'ArrayExpression',
elements: translations[key].map(text => { return { type: 'Literal', value: text } })
elements: translations[key].map(text => {
text = wrap(text.replace(/{{1}[^}]+}{1}/g, match => `$${match}`), '`')
const tree = new AbstractSyntaxTree(text)
tree.replace({ leave: node => {
if (node.type === 'Identifier') {
return getObjectMemberExpression(node.name)
}
}})
return tree.first('TemplateLiteral')
})
},

@@ -50,0 +62,0 @@ kind: 'init'

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