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

nested-html-loader

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nested-html-loader - npm Package Compare versions

Comparing version 0.3.1 to 0.3.2

4

index.js

@@ -18,6 +18,8 @@ /*

//preprocess html with nested html file link.
content = preprocessNestedHtml(content, this.resourcePath);
this.cacheable && this.cacheable();
var query = loaderUtils.parseQuery(this.query);
content = preprocessNestedHtml(content, this.resourcePath, query);
var attributes = ["img:src"];

@@ -24,0 +26,0 @@ if(query.attrs !== undefined) {

var fs = require("fs");
var path = require("path");
var replaceReg = /\{\{\include\:(.*?)}\}/g;
var replaceReg = /\{\{include\:(.*?)\}\}/g;
var conditionReg = /\{\{if\:\s*(.*?)\s*\}\}([\s\S]*?)\{\{\/if\s*\}\}/g;

@@ -16,4 +17,3 @@ function readFileContentByPath(path) {

module.exports = function preprocessNestedHtml(content, physicalPath){
var dir = path.dirname(physicalPath);
function handleInclude(content, dir) {
content = content.replace(replaceReg, function(match, rpath){

@@ -32,2 +32,21 @@ var actualPath;

return content;
}
}
function handleCondition(content, query) {
content = content.replace(conditionReg, function(match, expr, markup){
if(query[expr]) {
return markup;
}
return '';
});
return content;
}
function preprocessNestedHtml(content, physicalPath, query){
var dir = path.dirname(physicalPath);
content = handleInclude(content, dir);
content = handleCondition(content, query);
return content;
}
module.exports = preprocessNestedHtml
{
"name": "nested-html-loader",
"version": "0.3.1",
"version": "0.3.2",
"author": "Daniel @hujiang.com",

@@ -5,0 +5,0 @@ "description": "html loader module for webpack with additional fetures",

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