HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux wordpress-ubuntu-s-2vcpu-4gb-fra1-01 5.4.0-169-generic #187-Ubuntu SMP Thu Nov 23 14:52:28 UTC 2023 x86_64
User: root (0)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: //proc/1526/task/1529/cwd/tana/frontend/node_modules/gulp-nunjucks-render/index.js
'use strict';
var _ = require('lodash');
var PluginError = require('plugin-error');
var replaceExtension = require('replace-ext');
var through = require('through2');
var nunjucks = require('nunjucks');

var defaults = {
    path: '.',
    ext: '.html',
    data: {},
    inheritExtension: false,
    envOptions: {
      watch: false
    },
    manageEnv: null
};

module.exports = function (options) {
  options = _.defaultsDeep(options || {}, defaults);
  nunjucks.configure(options.envOptions);

  if (!options.loaders) {
    options.loaders = new nunjucks.FileSystemLoader(options.path);
  }

  var compile = new nunjucks.Environment(options.loaders, options.envOptions);

  if (_.isFunction(options.manageEnv)) {
    options.manageEnv.call(null, compile);
  }

  /*
   * file = file
   * cb   = callback function
   */
  return through.obj(function(file, enc, cb) {
    var data = _.cloneDeep(options.data);

    if (file.isNull()) {
      this.push(file);
      return cb();
    }

    if (file.data) {
      data = _.merge(file.data, data);
    }

    if (file.isStream()) {
      this.emit('error', new PluginError('gulp-nunjucks', 'Streaming not supported'));
      return cb();
    }

    var _this = this;

    var filePath = file.path;

    try {
      compile.renderString(file.contents.toString(), data, function (err, result) {
        if (err) {
          _this.emit('error', new PluginError('gulp-nunjucks', err, {fileName: filePath}));
          return cb();
        }
        file.contents = new Buffer(result);
        // Replace extension with mentioned/default extension
        // only if inherit extension flag is not provided(truthy)
        if (!options.inheritExtension) {
          file.path = replaceExtension(filePath, options.ext);
        }
        _this.push(file);
        cb();
      });
    } catch (err) {
      _this.emit('error', new PluginError('gulp-nunjucks', err, {fileName: filePath}));
      cb();
    }
  });
};

module.exports.setDefaults = function (options) {
  defaults = _.defaultsDeep(options || {}, defaults);
};

module.exports.nunjucks = nunjucks;