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

pug-linker

Package Overview
Dependencies
Maintainers
2
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pug-linker - npm Package Compare versions

Comparing version 1.0.2 to 2.0.0

52

index.js

@@ -63,7 +63,8 @@ 'use strict';

function findDeclaredBlocks(ast) {
function findDeclaredBlocks(ast) /*: {[name: string]: Array<BlockNode>}*/ {
var definitions = {};
walk(ast, function before(node) {
if (node.type === 'NamedBlock' && node.mode === 'replace') {
definitions[node.name] = node;
definitions[node.name] = definitions[node.name] || [];
definitions[node.name].push(node);
}

@@ -73,2 +74,15 @@ });

}
function flattenParentBlocks(parentBlocks, accumulator) {
accumulator = accumulator || [];
parentBlocks.forEach(function (parentBlock) {
if (parentBlock.parents) {
flattenParentBlocks(parentBlock.parents, accumulator);
} else {
accumulator.push(parentBlock);
}
});
return accumulator;
}
function extend(parentBlocks, ast) {

@@ -82,17 +96,18 @@ var stack = {};

stack[node.name] = node.name;
var parentBlock = parentBlocks[node.name];
if (parentBlock) {
if (parentBlock.parent) parentBlock = parentBlock.parent;
node.parent = parentBlock;
switch (node.mode) {
case 'append':
parentBlock.nodes = parentBlock.nodes.concat(node.nodes);
break;
case 'prepend':
parentBlock.nodes = node.nodes.concat(parentBlock.nodes);
break;
case 'replace':
parentBlock.nodes = node.nodes;
break;
}
var parentBlockList = parentBlocks[node.name] ? flattenParentBlocks(parentBlocks[node.name]) : [];
if (parentBlockList.length) {
node.parents = parentBlockList;
parentBlockList.forEach(parentBlock => {
switch (node.mode) {
case 'append':
parentBlock.nodes = parentBlock.nodes.concat(node.nodes);
break;
case 'prepend':
parentBlock.nodes = node.nodes.concat(parentBlock.nodes);
break;
case 'replace':
parentBlock.nodes = node.nodes;
break;
}
});
}

@@ -106,2 +121,3 @@ }

}
function applyIncludes(ast, child) {

@@ -118,2 +134,3 @@ return walk(ast, function before(node, replace) {

}
function applyYield(ast, block) {

@@ -147,2 +164,3 @@ if (!block || !block.nodes.length) return ast;

}
function checkExtendPosition(ast, hasExtends) {

@@ -149,0 +167,0 @@ var legitExtendsReached = false;

{
"name": "pug-linker",
"version": "1.0.2",
"version": "2.0.0",
"description": "Link multiple pug ASTs together using include/extends",

@@ -5,0 +5,0 @@ "keywords": [

var assert = require('assert');
var fs = require('fs');
var link = require('../');
var prettyStringify = require('./common').prettyStringify;
var assertObjEqual = require('./common').assertObjEqual;

@@ -7,0 +5,0 @@ function testDir (dir) {

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