How to use the pug.filter 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 nolimits4web / swiper-website / build / build-pages.js View on Github external
const gulp = require('gulp');
const gulpPug = require('gulp-pug');
const connect = require('gulp-connect');
const pug = require('pug');

const codeFilter = require('./utils/code-filter');
const codeInlineFilter = require('./utils/code-inline-filter');

if (!pug.filter && !pug.filters.code) {
  pug.filters = {
    code: codeFilter,
    code_inline: codeInlineFilter,
  };
}

function buildPages(cb, { src = ['**/index.pug'], dest = './public/' } = {}) {
  const cdn = process.argv.slice(3) ? process.argv.slice(3).toString().replace('-', '') !== 'local' : true;
  const time = Date.now();

  const name = src[0] === '**/*.pug' ? 'all' : src.join(', ');

  console.log(`Starting pug: ${name}`);

  gulp.src(src, { cwd: 'src/pug' })
    .pipe(gulpPug({
github framework7io / framework7-website / build / build-pages.js View on Github external
const pkg = require('../package.json');
const iconsManifest = require('./manifest-icons.json');

const getSrcFileUrl = require('./utils/get-src-file-url');
const getYamlData = require('./utils/get-yaml-data');
const inlineSvg = require('./utils/inline-svg');
const cssVars = require('./utils/css-vars');
const codeFilter = require('./utils/code-filter');
const codeInlineFilter = require('./utils/code-inline-filter');
const createIndex = require('./utils/create-index');
const createMobilePreviewLinks = require('./utils/create-mobile-preview-links');
const createInlineCodeTags = require('./utils/create-inline-code-tags');
const createCodeFilter = require('./utils/create-code-filter');

if (!pug.filter && !pug.filters.code) {
  pug.filters = {
    code: codeFilter,
    code_inline: codeInlineFilter,
  };
}

function buildPages(cb, { src = ['**/*.pug', '!**/_*.pug', '!_*.pug'], dest = './public' } = {}) {
  const cdn = process.argv.slice(3) ? process.argv.slice(3).toString().replace('-', '') !== 'local' : true;
  const time = Date.now();

  const name = src[0] === '**/*.pug' ? 'all' : src.join(', ');

  console.log(`Starting pug: ${name}`);

  gulp.src(src, { cwd: 'src/pug' })
    .pipe(gulpData((file) => { return { srcFileUrl: getSrcFileUrl(file) }; }))