New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

grunt-nunjucks

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

grunt-nunjucks - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

4

Gruntfile.js
module.exports = function(grunt) {
var tmpls = 'tasks/views/*';
var baseDir = 'tasks/views/';
var tmpls = baseDir + '*';

@@ -8,2 +9,3 @@ grunt.initConfig({

precompile: {
baseDir: baseDir,
src: tmpls,

@@ -10,0 +12,0 @@ dest: 'tasks/output/templates.js'

{
"name": "grunt-nunjucks",
"description": "Grunt task for precompiling nunjucks templates",
"version": "0.1.0",
"version": "0.1.1",
"homepage": "https://github.com/jlongster/nunjucks-grunt",

@@ -29,8 +29,7 @@ "author": {

"grunt": "~0.4.1",
"grunt-contrib-watch": "~0.5.3",
"nunjucks": "~0.1.10"
"grunt-contrib-watch": "~0.5.3"
},
"peerDependencies": {
"grunt": ">=0.4.1",
"nunjucks": ">=0.1.10"
"nunjucks": "*"
},

@@ -37,0 +36,0 @@ "keywords": [

@@ -47,4 +47,11 @@ # grunt-nunjucks

precompile: {
baseDir: 'views/',
src: 'views/*',
dest: 'static/js/templates.js'
options: {
env: require('./nunjucks-environment'),
name: function(filename) {
return 'foo/' + filename;
}
}
}

@@ -79,2 +86,9 @@ }

#### options.asFunction
Type: `Boolean` (default: `false`)
Compile each template as a callable function. Use this if you want to
compile each template file into a separate js file as a simple
callable object.
#### options.env

@@ -87,7 +101,6 @@ Type: `nunjucks.Environment`

#### options.asFunction
Type: `Boolean` (default: `false`)
#### options.name
Type: `function(filepath: string)` (default: filepath)
Compile each template as a callable function. Use this if you want to
compile each template file into a separate js file as a simple
callable object.
Define a function to transform each template's filepath into a template name.
These names are used with [`nunjucks.render`](http://jlongster.github.io/nunjucks/api.html#render).

@@ -11,6 +11,7 @@ /*

module.exports = function(grunt) {
module.exports = function (grunt) {
var nunjucks = require('nunjucks');
var lib = require('nunjucks/src/lib');
grunt.registerMultiTask('nunjucks', 'Precompile nunjucks', function() {
grunt.registerMultiTask('nunjucks', 'Precompile nunjucks', function () {
// Merge task-specific and/or target-specific options with these defaults.

@@ -22,4 +23,8 @@ var opts = this.options({

var files = this.files.forEach(function(f) {
var src = f.src.filter(function(filepath) {
var nameFunc = lib.isFunction(opts.name) ? opts.name : function(filepath) {
return filepath;
};
this.files.forEach(function (f) {
var src = f.src.filter(function (filepath) {
if (!grunt.file.exists(filepath)) {

@@ -32,2 +37,13 @@ grunt.log.warn('Source file "' + filepath + '" not found.');

}).map(function(filepath) {
if (f.baseDir) {
if (f.baseDir.substr(-1) !== '/') {
// Append a trailing slash, if there isn't one.
f.baseDir += '/';
}
if (filepath.substr(0, f.baseDir.length) === f.baseDir) {
// Strip leading `baseDir` from filename.
opts.name = filepath.substr(f.baseDir.length);
}
}
opts.name = nameFunc(filepath);
return nunjucks.precompile(filepath, opts);

@@ -34,0 +50,0 @@ }).join('');

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