【问题标题】:How to configure npm pug-php-filter with gulp?如何使用 gulp 配置 npm pug-php-filter?
【发布时间】:2017-04-14 11:29:44
【问题描述】:

我不知道如何使用 gulp 配置 pug-php-filter(https://www.npmjs.com/package/pug-php-filter) 以便我可以在 pug 文件中使用 php。
请帮我解决这个问题。

【问题讨论】:

  • 这个包有什么作用?
  • 我只知道这一点,它让我们在 pug 文件中使用 php。但我不知道如何在 gulp 中为 livereload 和所有配置它:(

标签: php html npm gulp pug


【解决方案1】:
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'));

});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-17
    • 1970-01-01
    • 1970-01-01
    • 2017-10-10
    • 2017-11-02
    • 1970-01-01
    • 1970-01-01
    • 2016-09-12
    相关资源
    最近更新 更多