javascript - 咕噜 Jade 编译

标签 javascript node.js express gulp pug

我正在使用gulp-jade我的模板之一出现此错误:

557| 
558| 
> 559| 
560|     .tabs-wrap(ng-show="eventExists"): .contain-center
561| 
562|       #room-tabs-contain.contain-disable.contain: .contain-center

unexpected token "pipeless-text"
at Parser.parseExpr (/Users/dylan/project/node_modules/jade/lib/parser.js:254:15)

乍一看,这是 github.com/jadejs/jade 中的一个错误。可能是这样,但我也使用 jade 来通过 Express 来服务器模板,并且当通过 Express 路由器时,模板完全符合要求,没有错误。

我尝试明确说明 gulp 使用的 jade 实例:

gulpjade = require 'gulp-jade'
jade = require 'jade'
locals = {}
gulp.src "#{config.client}/**/*.jade"
  .pipe gulpjade(jade: jade, pretty: true, locals: locals)
  .pipe gulp.dest("#{config.build}")

不过,还是没有运气。我想弄清楚的关键问题是:

  • 为什么这个jade模板通过express渲染得很好,但是通过gulp-jade就出错了

最佳答案

事实证明,我错了。实际上我没有成功地使用express 渲染模板。

正确的解决方案,我的模板遇到的错误是由于jade 1.9和1.11之间的变化

示例 1

  • 注释掉 .col-sm-3.text-right div

不好

//- .col-sm-3.text-right

//-
  .col-sm-3.text-right
<小时/>

示例 2

  • img 元素应该可见,.col-sm-3.text-right div 应被注释掉

不好

img(src="/image-path/png", alt="someimage")
  //- .col-sm-3.text-right

img(src="/image-path/png", alt="someimage")
//- .col-sm-3.text-right

关于javascript - 咕噜 Jade 编译,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31718402/

相关文章:

node.js - 错误 [ERR_HTTP_HEADERS_SENT] : Cannot set headers after they are sent to the client - Express + Request

javascript - 谷歌地图设置 DirectionsRenderer 对象的方向不绘制路线

javascript - 在 React 中更新父级中的状态时如何更新子级中的 props?

node.js - AWS CloudSearch 上传 JSON : Value tag cannot be array or object

ubuntu 上 Nodejs v0.6.12 出现 JSON.parse 错误

javascript - 是否可以在 Mongodb 上模拟大数据流?

javascript - jQuery的谷歌TTS没有声音

javascript - 将 Sinon 与 Typescript 和接口(interface)结合使用

node.js - 在 nodejs session 中使用 google memcache

html - 来自字符串格式问题的 Jade HTML