Skip to content

Instantly share code, notes, and snippets.

@fuddl
Last active August 29, 2015 14:11
Embed
What would you like to do?
jade php mixins

What is it?

Want to use php snippets inside of jade? Simply use php as mixins!

How to use

captains.jade:

h1 Awesome Captains
ul
  +php-foreach('$captains as $captain')
    li
      +php-print('$captain');

will convert into captains.php:

<h1>Awesome Captains</h1>
<ul>
  <?php foreach($captains as $captain): ?>
    <li>
      <?php print $captain; ?>
    </li>
  <?php endforeach; ?>
</ul>

will convert into captains.html:

<h1>Awesome Captains</h1>
<ul>
  <li>Jonathan</li>
  <li>James</li>
  <li>Jean-Luc</li>
  <li>Benjamin</li>
  <li>Kathryn</li>
</ul>
mixin php-foreach(expr)
| <?php foreach(!{expr}): ?>
block
| <?php endforeach; ?>
mixin php-print(expr)
| <?php print !{expr}; ?>
mixin php-if(expr)
| <?php if(!{expr}): ?>
block
| <?php endif; ?>
mixin php-for(expr)
| <?php for(!{expr}): ?>
block
| <?php endfor; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment