简体   繁体   English

pug-php中的href无效

[英]href in pug-php not working

Hi does anyone know how to use href in Pug? 嗨,有人知道如何在Pug中使用href吗?

What I want to achieve is this: 我要实现的是:

<noscript class="lazyload">
    <link rel="stylesheet" href="<?php echo get_template_directory_uri(); ?>/style.css">
</noscript>

I tried this, but it is not working. 我试过了,但是没有用。

noscript.lazyload
        link(rel='stylesheet', href!="<? php echo get_template_directory_uri(); ?>/style.css ")

This is my gulpfile.babel.js config: 这是我的gulpfile.babel.js配置:

import pug from 'gulp-pug'
import rename from 'gulp-rename'
import pugPHPFilter from 'pug-php-filter'

gulp.task('pug', () => {
    let option = {
        pretty: true,
        filters: {
            php: pugPHPFilter
        }
    }
    return gulp.src('./pug/*.pug')
        .pipe(pug(option))
        .pipe(rename({
            extname: '.php'
        }))
        .pipe(plumber())
        .pipe(gulp.dest('./'));
});

I convert your html to pug usign https://html2jade.org/ and this is the result: 我将您的html转换为pug usign https://html2jade.org/ ,结果如下:

  noscript.lazyload
    link(rel='stylesheet', href='<?php echo get_template_directory_uri(); ?>/style.css')

Try to assign PHP into Javascript var: 尝试将PHP分配给Javascript var:

noscript.lazyload
    -var template_uri = <?php echo get_template_directory_uri(); ?>
    link(rel='stylesheet', href=template_uri+'/style.css')

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM