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

simple-nunjucks-loader

Package Overview
Dependencies
Maintainers
1
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

simple-nunjucks-loader - npm Package Compare versions

Comparing version 1.0.0-alpha.0 to 1.0.0-alpha.1

lib/precompile/local-var-precompile.js

43

lib/loader.js

@@ -12,10 +12,6 @@ "use strict";

var _precompileTemplate = require("./precompile-template");
var _withDependencies = require("./precompile/with-dependencies");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function render(loader, source, options) {
return (0, _precompileTemplate.precompileTemplate)(loader, source, options);
}
function nunjucksLoader(source) {

@@ -37,10 +33,32 @@ const {

};
render(this, source, options).then(precompiled => {
(0, _withDependencies.withDependencies)(this.resourcePath, source, options).then(template => {
const {
dependencies,
precompiled
} = template;
return {
precompiled,
dependencies: dependencies.reduce((imports, {
fullPath
}) => {
this.addDependency(fullPath);
const path = JSON.stringify(fullPath);
return `
${imports}precompiledTemplates[${path}] = require(${path}).precompiled;
`;
}, '')
};
}).then(template => {
const {
dependencies,
precompiled
} = template;
const runtimeImport = `var runtime = require(${(0, _loaderUtils.stringifyRequest)(this, `${_path.default.resolve(_path.default.join(__dirname, 'runtime.js'))}`)});`;
const resourcePathString = JSON.stringify(this.resourcePath);
callback(null, `
var precompiledTemplates = {};
${runtimeImport}
${dependencies}
${precompiled}
module.exports = function nunjucksTemplate(ctx) {
${precompiled}
var nunjucks = runtime(

@@ -51,4 +69,7 @@ ${JSON.stringify(options)},

return nunjucks.render(${JSON.stringify(this.resourcePath)}, ctx);
};`);
return nunjucks.render(${resourcePathString}, ctx);
};
module.exports.precompiled = precompiledTemplates[${resourcePathString}];
`);
}, function (error) {

@@ -55,0 +76,0 @@ callback(error);

{
"name": "simple-nunjucks-loader",
"version": "1.0.0-alpha.0",
"version": "1.0.0-alpha.1",
"description": "Webpack loader for Nunjucks",

@@ -10,3 +10,6 @@ "main": "lib/loader.js",

"test": "jest",
"posttest": "rm -rf ./test/bundles/"
"posttest": "rm -rf ./test/bundles/",
"preversion": "npm test",
"postversion": "git push && git push --tags",
"prepublishOnly": "npm run build"
},

@@ -13,0 +16,0 @@ "repository": {

@@ -1,2 +0,2 @@

# nunjucks-loader
# Nunjucks templates loader for Webpack
This Webpack loader compiles [Nunjucks](https://github.com/mozilla/nunjucks) templates.

@@ -3,0 +3,0 @@ [`html-webpack-plugin`](https://github.com/jantimon/html-webpack-plugin) compatible.

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