如何用gulp配置npm pug-php-filter?

时间:2017-04-14 11:29:45

标签: php html npm gulp pug

我无法弄清楚如何使用gulp配置pug-php-filter(https://www.npmjs.com/package/pug-php-filter)以便我可以在pug文件中使用php。
Plz帮助我。

1 个答案:

答案 0 :(得分:2)

var rename = require('gulp-rename');
var pug = require('gulp-pug'),
    pugPHPFilter = require('pug-php-filter');

gulp.task('pug', function() {
  return gulp.src('./_pugfiles/**/*.pug')
   .pipe( pug({
       pretty: "\t",
       filters: {
        php: pugPHPFilter
    }
}) )
   .pipe(rename(function (path) {
      path.extname = ".php"
    }))
  .pipe(gulp.dest('./site'));

});