How to use the swig.renderFile function in swig

To help you get started, we’ve selected a few swig 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 VisualComposer / builder / tools / refactor-element-builder / index.js View on Github external
let renderTemplate = (data) => {
  let compiledTemplate = swig.renderFile(path.join(__dirname, 'index-template.jst'), data)
  compiledTemplate = compiledTemplate.replace(/"require\((.[^\)]*)\)"/g, ' require($1)')

  return compiledTemplate
}
github sahat / newedenfaces-react / server.js View on Github external
Router.match({ routes: routes.default, location: req.url }, function(err, redirectLocation, renderProps) {
    if (err) {
      res.status(500).send(err.message)
    } else if (redirectLocation) {
      res.status(302).redirect(redirectLocation.pathname + redirectLocation.search)
    } else if (renderProps) {
        var html = ReactDOM.renderToString(React.createElement(Router.RoutingContext, renderProps));
        var page = swig.renderFile('views/index.html', { html: html });
        res.status(200).send(page);
    } else {
      res.status(404).send('Page Not Found')
    }
  });
});
github BerkeleyBlockchain / BlockChange / server.js View on Github external
Router.match({ routes: routes.default, location: req.url }, function(err, redirectLocation, renderProps) {
        if (err) {
            res.status(500).send(err.message)
        } else if (redirectLocation) {
            res.status(302).redirect(redirectLocation.pathname + redirectLocation.search)
        } else if (renderProps) {
            var html = ReactDOM.renderToString(React.createElement(Router.RouterContext, renderProps));
            var page = swig.renderFile('views/index.html', { html: html });
            res.status(200).send(page);
        } else {
            res.status(404).send('Page Not Found')
        }
    });
});
github genify / toolkit2 / main.js View on Github external
exports.init = function(output){
    output = _path.absolute(
        output+'/',process.cwd()+'/'
    );
    var content = require('swig').renderFile(
        __dirname+'/template/release.conf',{
            comment:'#',
            DIR_WEBROOT:'../webapp/'
        }
    );
    _fs.write(output+'release.conf',content);
    _logger.info('output release.conf to %s',output);
};
/**
github GongDexing / work-board / server / server.js View on Github external
app.get('/', (req, res) => {
  const page = swig.renderFile('index.html');
  res.status(200).send(page);
});

swig

A simple, powerful, and extendable templating engine for node.js and browsers, similar to Django, Jinja2, and Twig.

MIT
Latest version published 10 years ago

Package Health Score

52 / 100
Full package analysis