Open Collective
Open Collective
Loading

Phug

PHP template engine based on Pug syntax

About


Phug is the pug template engine for PHP.

Phug offer you a clean way to write your templates (such as HTML pages) using indentation to structure the hierarchy of elements and providing an easy way to interpolation values in contents and attributes.

doctype html
html(lang="en")
  head
    title= $pageTitle
    script(type='text/javascript').
      if (foo) {
         bar(1 + 5)
      }
  body
    h1= $pageTitle
    #container.col
      if $youAreUsingPhug
        p You are amazing
      else
        p Get on it!
      p.
        Phug is PHP port Pug (JS)
        the node template engine.

With data like:

[
  'pageTitle' => 'Try Phug and never recode HTML again',
  'youAreUsingPhug' => true,
]

Get:

<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Try Phug and never recode HTML again</title>
    <script type="text/javascript">if (foo) {
   bar(1 + 5)
}</script>
  </head>
  <body>
    <h1>Try Phug and never recode HTML again</h1>
    <div id="container" class="col">
      <p>You are amazing</p>
      <p>Phug is PHP port Pug (JS) the node template engine.</p>
    </div>
  </body>
</html>

Our team