简体   繁体   中英

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:
 <a href="http://&lt;?php echo $link; ?&gt;/thelink.php">thelink</a>
My problem are "&lt" and "&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.

You can then use PHP variables (and objects) within PHP pretty easily. See this example:

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

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

PHUG transforms this to:

// 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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