pg-generator nunjucks插入了不必要的空格,html正在破坏

时间:2016-07-27 15:10:16

标签: javascript templates nunjucks

我正在尝试生成一些反应html但是插入了奇怪的空格来打破html。

请帮助!!!!

使用基本模板

使用命令运行 Rd NaN NaN Rd/DLEPC NaN NaN

我的模板文件:

pgen exec pg-generator-templates/react-crud-template/ -d convectorFeathersServer -u postgres -p postgres -t src/react-crud-build

结果

<!doctype html>
<html lang="en">
  <head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css">
<title>React App</title>
</head>
<body>
<div id="root"></div>
<script src="bundle.js"></script>
</body>

1 个答案:

答案 0 :(得分:0)

https://github.com/ozum/pg-generator/issues/30

ozum 2小时前评论过 您好,

那很奇怪。也许pg-generator使用的js-beautify可能是理由。

请您评论一下lib / index.js的第119-121行

   if (path.extname(target) === '.js' || path.extname(target) === '.html') {
        content         = beautify(content, this.beautyOptions);
    }
  // if (path.extname(target) === '.js' || path.extname(target) === '.html') {
  //      content         = beautify(content, this.beautyOptions);
  //  }

该函数中的内容是生成要写入文件的文本。请报告结果,所以我可以想办法解决这个问题。