How to use the pug.compileFile function in pug

To help you get started, we’ve selected a few pug 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 AndreyUtka / angular-typescript-starter-kit / build-process / build-tpl.js View on Github external
const pug = require("pug");
const fs = require("fs");
const path = require("path");
const buildConstants = require("./build-constants");

// Compile the source code
const compiledFunction = pug.compileFile("src/index.pug", null);
const html = compiledFunction({});

fs.writeFile(path.resolve(`${buildConstants.out}/index.html`), html, function (err) {
    if (err) throw err;
});
github elifesciences / elife-xpub / server / xpub-server / entities / manuscript / resolvers.js View on Github external
? ManuscriptManager.getAuthor(originalManuscript)
        : [].map(author => author.alias.email).join(',')

      const manuscript = ManuscriptManager.applyInput(originalManuscript, data)

      const newAuthors = ManuscriptManager.getAuthor(manuscript)
      const newAuthorEmails = newAuthors
        .map(author => author.alias.email)
        .join(',')

      // Send email here only when author changes...
      if (newAuthorEmails !== originalAuthorEmails) {
        const textCompile = pug.compileFile(
          'templates/dashboard-email-text.pug',
        )
        const htmlCompile = pug.compileFile(
          'templates/dashboard-email-html.pug',
        )
        const text = textCompile({
          authorName: newAuthors[0].alias.firstName,
          linkDashboard: config.pubsweet.base_url,
        })
        const html = htmlCompile({
          authorName: newAuthors[0].alias.firstName,
          linkDashboard: config.pubsweet.base_url,
        })

        mailer
          .send({
            to: newAuthorEmails,
            subject: 'Libero Submission System: New Submission',
            from: 'editorial@elifesciences.org',
github freeCodeCamp / testable-projects-fcc / gulpfile.js View on Github external
const path = require('path');
const { pipeline } = require('stream');

const gulp = require('gulp');
const through2 = require('through2');
const Vinyl = require('vinyl');
const concat = require('gulp-concat');
const watch = require('gulp-watch');
const babel = require('gulp-babel');
const sass = require('gulp-sass');

const pug = require('pug');

sass.compiler = require('node-sass');

const compileHtml = pug.compileFile('./src/projects/index.pug');

const babelOptions = {
  babelrc: false,
  presets: ['@babel/preset-env', '@babel/preset-react']
};
const noop = () => {};

const bundle =
  process.env.BUNDLE_URL || '../../testable-projects-fcc/v1/bundle.js';
const projectsPath = process.env.PROJECTS_PATH || './src/projects';
const buildPath = process.env.BUILD_PATH || './build/pages';

function js(projectPath) {
  return pipeline(
    gulp.src(projectPath + '/**/*.{js,jsx}'),
    babel(babelOptions).on('error', err => {
github WagonOfDoubt / kotoba.js / app / src / models / style.js View on Github external
/**
 * Model for user-defined styles.
 * @module models/style
 */

const mongoose = require('mongoose');
const Schema = mongoose.Schema;
const ObjectId = Schema.Types.ObjectId;
const defaultSyles = require('../json/defaultstyles.json');
const path = require('path');
const _ = require('lodash');
const config = require('../json/config.json');
const pug = require('pug');
const userStyleTemplate = pug.compileFile(
  path.join(config.templates_path, 'includes/userstyle.pug'));


const nameValidators = [
  {
    validator: function(v) {
      return /^[a-z0-9_]*$/.test(v);
    },
    message: 'style name can contain only letters and numbers'
  },
];


/**
 * Style model
 * @class Style
github SE7ENSKY / webpack-verstat / bin / core.js View on Github external
function compileTemplate(filePath, globalData = GLOBAL_DATA, blocks = BLOCKS, commons = COMMONS) {
	const extractedData = loadFront(filePath, '\/\/---', 'content');
	const modifiedExtractedData = Object.assign({}, extractedData);
	delete modifiedExtractedData.layout;
	delete modifiedExtractedData.content;
	const extractedDataLayout = extractedData.layout;
	const layoutIndex = extractedDataLayout ? LAYOUTS.findIndex(item => item.indexOf(normalize(extractedDataLayout)) > -1) : -1;
	if (layoutIndex > -1) {
		const layout = LAYOUTS[layoutIndex];
		const fnLayout = compileFile( layout, {
			compileDebug: true,
			inlineRuntimeFunctions: true,
			plugins: [
				{
					preLex: function(fileSource, someOpts) {
						const extendsReg = /^extends/;
						const rootReg = /\/layouts\/root\.?(pug|jade)/;
						if (rootReg.test(someOpts.filename) || !extendsReg.test(fileSource)) {
							return `${commons}\n${bemto}\n${fileSource}`;
						}
						return fileSource;
					}
				}
			]
		});
		siteGridEngine(
github rimiti / invoice-it / src / classes / generator.js View on Github external
_compile(keys) {
    const template = keys.filename === 'order' ? this.order_template : this.invoice_template;
    const compiled = pug.compileFile(path.resolve(template));
    return compiled(keys);
  }
github eshengsky / noginx / web / route.js View on Github external
* @Date: 2018-02-07 12:02:40 
 * @Last Modified by: Sky.Sun
 * @Last Modified time: 2019-06-12 16:27:32
 */
const express = require('express');
const router = express.Router();
const path = require('path');
const session = require('express-session');
const MongoStore = require('connect-mongo')(session);
const passport = require('passport');
const Strategy = require('passport-local').Strategy;
const ensureLogin = require('connect-ensure-login');
const serverlog = require('serverlog-node');
const logger = serverlog.getLogger('noginx-webui');
const pug = require('pug');
const routeCompiledFunc = pug.compileFile('./web/views/partials/route-tr.pug');
const serverCompiledFunc = pug.compileFile('./web/views/partials/server-item.pug');
const permissionCompiledFunc = pug.compileFile('./web/views/partials/permission-tr.pug');
const cacheCompiledFunc = pug.compileFile('./web/views/partials/cache-tr.pug');
const domainCompiledFunc = pug.compileFile('./web/views/partials/domain-tr.pug');
const mongoose = require('../db').mongoose;
const routeModel = require('../models/routes').routeModel;
const serverModel = require('../models/servers').serverModel;
const permissionModel = require('../models/permissions').permissionModel;
const cacheModel = require('../models/caches').cacheModel;
const domainModel = require('../models/domains').domainModel;
const configPath = require('../getConfigPath')();
const config = require(configPath);
const userConfig = config.auth.users;
const canEdit = require('./auth').canEdit;
const authMw = require('./auth').authMw;
const common = require('../utilities/common');
github kucherenko / jscpd / src / reporters / html.ts View on Github external
public report(clones: IClone[], statistic: IStatistic): void {
    const reportFunction = compileFile(__dirname + '/../../html/report.pug');

    const formatsReports: any[] =
      statistic && statistic.formats
        ? Object.keys(statistic.formats).map(format => {
            return { value: statistic.formats[format].total.lines, name: format };
          })
        : [];

    const html = reportFunction({
      total: {},
      ...statistic,
      formatsReports,
      clones,
      getPath,
      getSourceLocation,
      generateLine,
github iwonz / html-only-chat / index.js View on Github external
messages.forEach((message) => {
    message.dt = hdate.relativeTime(new Date(message.dt));

    messagesHTML += pug.compileFile('views/message.pug')({
      user: users.get(message.userId),
      message
    });
  });
github getgridea / gridea / src / renderer / lib / util / post.js View on Github external
async _renderHtmlWithLayout(content, config) {
    const template = pug.compileFile(`${config.templatePath}/layout.pug`, {
      filename: 'index.html',
      basedir: config.templatePath,
      pretty: true,
    })
    const html = template({
      website: config.website,
      domain: config.domain,
      content: content,
    })
    return html
  }