How to use the nunjucks.SafeString function in nunjucks

To help you get started, we’ve selected a few nunjucks examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github frctl / fractal / packages / pages / src / engine / extensions / component.js View on Github external
async run(context, target, ...args) {
    const callback = args.pop();
    const data = args.shift() || {};
    const opts = args.shift() || {};

    try {
      const [name, ext] = target.split('.');
      const variant = lookup(name, context.env.components);
      if (!variant) {
        throw new Error(`Component extension - Could not find '${name}'`);
      }
      target = variant;
      opts.ext = opts.ext || (ext ? `.${ext}` : null);
      const result = await context.env.fractal.render(target, data, opts);
      callback(null, new SafeString(result));
    } catch (err) {
      callback(err);
    }
  }
};
github frctl / fractalite / packages / app / src / render-extension.js View on Github external
environment.env.renderString(body(), environment.ctx, (err, html) => {
      if (err) {
        console.log(err);
        return done(err);
      }
      done(null, new SafeString(html));
    });
  };
github frctl / fractalite / packages / adapter-nunjucks / src / extension-component.js View on Github external
env.render(component.name, props, (err, result) => {
      if (err) {
        return callback(err);
      }
      callback(null, new SafeString(result));
    });
  }
github frctl / fractal / packages / fractal-engine-nunjucks / src / extensions / include-with.js View on Github external
env.render(name, tplData, (err, result) => {
      if (err) {
        return callback(err);
      }
      callback(null, new SafeString(result));
    });
  }
github frctl / fractalite / packages / ui / src / engine / filters / render.js View on Github external
module.exports = async function render(target, args, ui) {
  let html = await ui.app.render(target, ...args);
  html = ui.utils.resolveUrlRefs(html);
  return new SafeString(html);
};