简体   繁体   English

如何在 PUG 上的锚链接中正确添加 PHP 标签

[英]How to properly add a PHP tag inside anchor link on PUG

This is what i have done: 这是我所做的:
    <a href="http://<?php echo $link; ?>/thelink.php">thelink</a>
PUG compiles to: PUG 编译为:
 <a href="http://&lt;?php echo $link; ?&gt;/thelink.php">thelink</a>
My problem are "&lt" and "&gt". 我的问题是“&lt”和“&gt”。 How can i properly compile it to?: 我怎样才能正确编译它?:
 <a href="http://<?php echo $link; ?>/thelink.php">thelink</a>

I recommend using Phug when using Pug with PHP.我建议在将 Pug 与 PHP 一起使用时使用Phug

You can then use PHP variables (and objects) within PHP pretty easily.然后,您可以非常轻松地在 PHP 中使用 PHP 变量(和对象)。 See this example:看这个例子:

// PHP
mixin link($href, $name)
   a(href=$href)&attributes($attributes)= $name

+link('/foo', 'foo')(class="btn")

PHUG transforms this to: PHUG 将其转换为:

// HTML
<a class="btn" href="/foo">foo</a>

You can read more about this specific example in the documentation .您可以在文档中阅读有关此特定示例的更多信息。

Use "!"用 ”!” before "=" :在“=”之前:

a(href!="http://<?php echo $link; ?>/thelink.php") thelink

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

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