Skip to content

Instantly share code, notes, and snippets.

@fuddl
Last active August 29, 2015 14:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fuddl/644b6ffd132107473e89 to your computer and use it in GitHub Desktop.
Save fuddl/644b6ffd132107473e89 to your computer and use it in GitHub Desktop.
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