示例#1
0
 return Promise.all(promises).then(function (list) {
     if (hasUninlineResource) {
         var result = htmlmin(list.join(''), { jsmin: true, removeComments: true });
         return writeFile(distFile, componentFlag + '\n' + result).then(function () {
             log(chalk.green('[HTML DONE] ') + htmlPath, indent);
         });
     }
 });
示例#2
0
 function(htmlDistData, callback) {
     fs.writeFile(paths.DIST + 'index.html',
         htmlmin(htmlDistData), 'utf8',
         function(err) {
             if (err) callback(errorCodes.WRITE_PAPER_HTML);
             else callback(null);
         }
     );
 }
示例#3
0
文件: router.js 项目: einse/weatherw
        var widgets = Object.keys(allPlaces).map(function (cityCode) {
            var widgetOptions = {
                cityCode: cityCode,
                timeSpan: '1d'
            };

            return {
                place: allPlaces[cityCode],
                embedCode: htmlmin(renderWidget.embed(widgetOptions))
            };
        });
    fileTypeList(".mustache").forEach(function(inFile){
      var outFile = outputFile(inFile, ".html"),
          output  = ""+fs.readFileSync(inFile);
      console.log(inFile, "->", outFile);

      setActive(outFile, data);
      output = data.php.replaceVars(output);
      output = mustache.render(output, data, partials);

      if (!debug) { output = htmlmin(output, htmlmin_opts); }
      jake.mkdirP(path.dirname(outFile));
      fs.writeFileSync(outFile, output);
    });
    fileTypeList(".md").forEach(function(inFile){
      var outFile = outputFile(inFile, ".html"),
          output  = ""+fs.readFileSync(inFile);
      console.log(inFile, "->", outFile);

      setActive(outFile, data);
      var template = "{{> _markdown }}";
      var lines = output.trim().split("\n");
      if (lines[lines.length-1].substr(0, 3) === "{{>")
        template = lines.pop();
      data.title = lines[0].trim();
      data.yield = markdown(lines.join("\n"));
      output = mustache.render(template, data, partials);

      if (!debug) { output = htmlmin(output, htmlmin_opts); }
      jake.mkdirP(path.dirname(outFile));
      fs.writeFileSync(outFile, output);
    });
示例#6
0
function htmlProcessor(contents, classes) {
  const htmlAst = html.parse(contents);
  const config = new Config();
  const verbose = Verbose.getInstance(config.rc.verbose);

  function processNode(node) {
    node = config.rc.presets.html.reduce((convertedNode, converter) => {
      return converter(convertedNode, classes, minify, verbose);
    }, node);

    if (node.childNodes && node.childNodes.length) {
      node.childNodes = node.childNodes.map((childNode) => processNode(childNode));
    }

    return node;
  }

  return htmlmin(html.serialize(processNode(htmlAst)));
}
示例#7
0
  function processFileData(route, html) {

    if (basePath)
      route = route.replace(basePath + '/', '');
    if (route.indexOf('.jade') !== -1)
      html = jade.render(html, {pretty: true});
    if (minify)
      html = htmlmin(html, {
        collapseBooleanAttributes: true,
        collapseWhitespace: true,
        removeComments: true
      });

    html = html.replace(/\\/g, '\\\\');
    html = html.replace(/'/g, '\\\'');
    html = html.replace(/\r?\n/g, '\\n\' +\n    \'');

    //if (quotes)
    //html = html. replace("'", '"')

    return util.format(templateCache, route, html)
  }
示例#8
0
文件: core.js 项目: ywo/ywo
    html2js : function (htmlStr, config) {
        config = config || {};
        htmlStr = htmlmin(htmlStr).trim()
           .replace(/[\r\n\t]/g, ' ')
           .replace(/\s+/g, ' ')
           .replace(/\\/g, '\\\\')
           .replace(/'/g, '\\x27')
           .replace(/"/g, '\\x22')
           .replace(/\//g, '\\/')
           .replace(/\n/g, '\\n')
           .replace(/\r/g, '\\r')
           .replace(/\t/g, '\\t');

        if(config.useWrite) {
            htmlStr =
                '(function(str){' +
                    'setTimeout(function(){' +
                        'document.documentElement ? document.documentElement.innerHTML = str : document.write(str);' +
                    '});' +
                '})("' +htmlStr+ '")';
        }
        return htmlStr;
    },