UNPKG

sequelize-admin-panel

Version:
116 lines (91 loc) 3.03 kB
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>JSDoc: Source: middleware/pugrender.js</title> <script src="scripts/prettify/prettify.js"> </script> <script src="scripts/prettify/lang-css.js"> </script> <!--[if lt IE 9]> <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css"> <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css"> </head> <body> <div id="main"> <h1 class="page-title">Source: middleware/pugrender.js</h1> <section> <article> <pre class="prettyprint source linenums"><code>var pug = require('pug') const path = require('path') // /** // * @namespace req // * @description express request object // * @prop {Function} pugrenderToString(fname,locals) // * find template as __dirname+'../views/'+fname and renders with locals // * returns string // */ // /** // * @namespace res // * @description express responce object // * @prop {Function} pugrender(fname,locals) // * find template as __dirname+'../views/'+fname, renders with locals and send // */ /** * @namespace req */ /** * @namespace res */ function abspath(fname) { if (fname.charAt(0) === '/') return fname return path.join(__dirname, '../views', fname) + '.pug' } module.exports = (req, res, next) => { /** * Find template at __dirname+'../views/' and renders with locals * @method req.pugrenderToString * @param {String} fname template name * @param {Object} locals template locals */ req.pugrenderToString = (fname, locals) => { return pug.renderFile( abspath(fname), Object.assign({}, locals, { req }) ) } /** * Find template at __dirname+'../views/', renders with locals and send * @method res.pugrender * @param {String} fname template name * @param {Object} locals template locals */ res.pugrender = (fname, locals) => { res.send( pug.renderFile( abspath(fname), Object.assign({}, locals, { req }) ) ) } next() } </code></pre> </article> </section> </div> <nav> <h2><a href="index.html">Home</a></h2><h3>Modules</h3><ul><li><a href="module-cli.html">cli</a></li><li><a href="module-sequelize-admin-panel.html">sequelize-admin-panel</a></li></ul><h3>Classes</h3><ul><li><a href="ModelAdmin.html">ModelAdmin</a></li><li><a href="ModelAdminManager.html">ModelAdminManager</a></li></ul><h3>Namespaces</h3><ul><li><a href="req.html">req</a></li><li><a href="req.SA.html">SA</a></li><li><a href="req.SA.utils.html">utils</a></li><li><a href="res.html">res</a></li></ul> </nav> <br class="clear"> <footer> Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Wed May 30 2018 09:23:34 GMT+0700 (+07) </footer> <script> prettyPrint(); </script> <script src="scripts/linenumber.js"> </script> </body> </html>