コード例 #1
0
ファイル: index.js プロジェクト: badoet/meltingpot
 fs.readFile('views/' + req.params.page +'.pug', 'utf8', function(err, view) {
   if (err) {
     res.end( "<div>No Page Found</div>" );
   } else {
     res.end( pug.render(view) );
   }
 });
コード例 #2
0
ファイル: gulpfile.js プロジェクト: esarbanis/ng-lightning
 templateProcessor: function(filepath, ext, file, cb) {
   const rendered = pug.render(file, {
     doctype: 'html',
     filename: filepath,
   });
   cb(null, rendered);
 },
コード例 #3
0
ファイル: styleguide.js プロジェクト: aj-dev/sc5-styleguide
  function convertToPug(section) {
    var cacheKey, pugstring, md5;

    if (!section.markup) { return; }
    if (/<[a-z][\s\S]*>/i.test(section.markup)) { return; }

    section.markupPug = section.markup;

    if (section.reference) {
      parentref = section.reference;
      cacheKey = section.reference;
    } else {
      cacheKey = parentref + ' - ' + section.name;
    }

    pugstring = bemtoinclude + section.markup;
    md5 = crypto.createHash('md5').update(pugstring).digest('hex');

    if (pugCache.getItem(cacheKey) && pugCache.getItem(cacheKey).key === md5) {
      section.markup = pugCache.getItem(cacheKey).value;
    } else {
      section.markup = pug.render(pugstring, pugOptions);
      pugCache.setItem(cacheKey, {
        key : md5,
        value : section.markup
      });
    }

    if (section.modifiers) {
      _.each(section.modifiers, convertToPug);
    }
  }
コード例 #4
0
  var getContent = function (filepath, options) {
    var content = grunt.file.read(filepath);
    if (isPugTemplate(filepath)) {
      var pug = require('pug');
      options.pug.filename = filepath;
      content = pug.render(content, options.pug);
    }

    // Process files as templates if requested.
    var process = options.process;
    if (typeof process === 'function') {
      content = process(content, filepath);
    } else if (process) {
      if (process === true) {
        process = {};
      }
      content = grunt.template.process(content, process);
    }

    if (Object.keys(options.htmlmin).length) {
      try {
        content = minify(content, options.htmlmin);
      } catch (err) {
        grunt.warn(filepath + '\n' + err);
      }
    }

    // trim leading whitespace
    content = content.replace(/(^\s*)/g, '');

    return escapeContent(content, options.quoteChar, options.indentString, options.templatePathInComment ? filepath : '');
  };
コード例 #5
0
ファイル: blog_post.js プロジェクト: kylesmile/website
 parsedBody() {
   try {
     return pug.render(this.body(), {});
   } catch(error) {
     console.log(error);
     return "<p>There was a problem with this blog post</p>";
   }
 }
コード例 #6
0
 function(err, result) {
   if (err) {
     console.error(err);
     return;
   }
   var nodes = parser(pug.render(result, {pretty: true}));
   resolve(nodes);
 });
コード例 #7
0
ファイル: core.spec.js プロジェクト: riot/compiler
 registerPreprocessor('template', 'pug', (code, {file}) => {
   return {
     code: pug.render(code, {
       filename: file
     }),
     map: {}
   }
 })
コード例 #8
0
ファイル: fetchResume.js プロジェクト: pciapcib/cv
  fs.readFile(path.resolve(__dirname, '../../components/ResumeText.vue'), (err, data) => {
    if (err) throw err

    const pugOut = data.toString().replace(/\n {4}/g, '\n').match(resumeReg)[1]
    const xmlOut = pug.render(pugOut, { pretty: true }).slice(1)

    fs.writeFileSync(path.resolve(__dirname, '../text/resume-pug.txt'), pugOut)
    fs.writeFileSync(path.resolve(__dirname, '../text/resume-xml.txt'), xmlOut)
  })
コード例 #9
0
ファイル: server.js プロジェクト: kwv/podcastslinger
 .then(function(content) {
   console.log(content);
   return pug.render(content, options, function(err, xml) {
     console.log(xml)
     if (err) {
       throw err;
     }
     return xml;
   });
 })
コード例 #10
0
ファイル: index.js プロジェクト: alexshuhin/gulp-pug
  return through.obj(function stream(file, enc, callback) {
    let error = null;

    if (file.isBuffer()) {
      const contents = pug.render(file.contents.toString(), opts);
      file.contents = new Buffer(contents);
    } else {
      error = new PluginError('gulp-pug', 'Unsupported file content');
    }

    file.path = replaceExtension(file.path, '.html');

    callback(error, file);
  });
コード例 #11
0
ファイル: index.js プロジェクト: ntzyz/new-blog
    fs.readFile(path.resolve(__dirname, './rss2.pug'), 'utf-8', (err, template) => {
      const xml = pug.render(template, {
        title: config.title,
        link: config.url + '/',
        feedUrl: config.url + '/feeds',
        language: config.language,
        description: '',
        posts: utils.render(posts, { preview: false, acceptLanguage }),
        renderedPosts: utils.render(posts, { preview: true, acceptLanguage }),
        cdata (text, options) {
          return '<![CDATA[' + text.replace(/\]\]>/g, ']]]]><![CDATA[>') + ']]>';
        }
      });

      resolve(xml);
    });
コード例 #12
0
 through.obj((file, encoding, callback) => {
   const pugContents = file.isBuffer()
     ? file.contents.toString(encoding)
     : file.contents;
   pug.render(
     pugContents,
     {...file.data, filename: file.path, pretty: true},
     (error, htmlContents) => {
       if (error) {
         callback(error);
         return;
       }
       file.contents = Buffer.from(htmlContents);
       file.path = filename
         ? path.join(path.dirname(file.path), filename)
         : file.path.replace(/\.pug$/, ".html");
       callback(null, file);
     },
   );
 });
コード例 #13
0
ファイル: index.js プロジェクト: sourcejs/sourcejs-jade
exports.process = function (req, res, next) {
    if (req.specData && req.specData.renderedHtml) {
        if (req.specData.isJade || req.specData.isPug) {
            var html = req.specData.renderedHtml;
            var specDir = specUtils.getFullPathToSpec(req.path);
            var specFiles = configUtils.getContextOptions(req.path).rendering.specFiles;
            var specFilePath = specUtils.getSpecFromDir(specDir, specFiles);

            /* render jade markup */
            html = pug.render(html, {
                pretty: true,
                basedir: global.app.get('user'),
                filename: specFilePath
            });

            req.specData.renderedHtml = html;
        }
    }

    next();
};
コード例 #14
0
ファイル: webpack.config.js プロジェクト: kcsry/infokala
 transform: (content, path) => {
   return pug.render(content, { compileDebug: !isProd }, path);
 }
コード例 #15
0
ファイル: index.js プロジェクト: judas-christ/static2000-pug
 render: function(source, options) {
   source = renamePlugins(source, options);
   return pug.render(source, options);
 }
コード例 #16
0
ファイル: serve.js プロジェクト: feihong/elm-examples
async function renderTemplate(pugFile) {
  let text = await readFile(pugFile)
  return pug.render(text, {filename: pugFile, basedir: templateDir})
}
コード例 #17
0
ファイル: common.js プロジェクト: badoet/meltingpot
 renderIndexPage: function(res) {
   var view = fs.readFileSync('views/index.pug', 'utf8');
   res.end( pug.render(view) );
 }
コード例 #18
0
ファイル: index.js プロジェクト: jostylr/literate-programming
Folder.sync("pug" , function (code, args) {
    var options = merge(true, this.plugins.pug, args);
    return pug.render(code, options); 
});