【发布时间】:2016-01-14 20:41:37
【问题描述】:
当我使用 gulp-jade@1.1.0 编译“index.jade”时
<!DOCTYPE html>
html(lang="en")
head
meta(charset="UTF-8")
title Document
body
- var json = {'foo': 'bar'}
include template
包括“template.jade”
h1= json.foo
gulp-jade 总是报这样的错误
[15:11:34] Starting 'jade'...
[15:11:34] Starting 'sass'...
[15:11:34] Finished 'sass' after 2.68 ms
[15:11:34] Plumber found unhandled error:
TypeError in plugin 'gulp-jade'
Message:
C:\Users\Administrator\Desktop\workspace\node\src\jade\template.jade:1
> 1| h1= json.foo
Cannot read property 'foo' of undefined
Details:
path: C:\Users\Administrator\Desktop\workspace\node\src\jade\template.jade
[15:11:34] Finished 'jade' after 19 ms
但是编译后的html文件是对的
<!DOCTYPE html>
<html lang="en"></html>
<head>
<meta charset="UTF-8"/>
<title>Document</title>
</head>
<body>
<h1>bar</h1>
</body>
我的 gulpfile 是这样写的
gulp.task('jade', function(){
return gulp.src('src/jade/*.jade')
.pipe(plumber())
.pipe(gulpJade({
jade: jade,
pretty: true
}))
.pipe(gulp.dest('build/html'))
.pipe(connect.reload());
});
【问题讨论】: