Using plain PHP templates

Let’s take the unaltered default theme as an example. In views/layouts we have the default template which calls a render_partial for the _header partial.

views/layouts/default.html.pug
doctype html
html
  head= render_partial("layouts/head")
  body
    .page-wrapper
      header.site-header= render_partial("layouts/header")
      section.site-content= wl_yield()
      footer.site-footer= render_partial("layouts/footer")
    // jQuery and application.js is loaded by default with wp_footer() function. See config/initializers/default_hooks.php for details
    - wp_footer()
views/layouts/_header.html.pug
h1!= link_to(get_bloginfo('name'), get_bloginfo('url'))
h2= get_bloginfo('description')

Let’s suppose we need to change _header in a PHP template because we don’t like PUG or we need to write complex code there.

Warning

If you have to write complex code in a view you are on the wrong path :)

  1. Rename _header.html.pug in _header.html.php

  2. Update its content, e.g.:

    views/layouts/_header.html.php
    <h1> <?php echo link_to(get_bloginfo('name'), get_bloginfo('url')); ?> </h1>
    <h2> <?php echo htmlentities(get_bloginfo('description')) ?> </h2>
    
  3. Done

When render_partial("layouts/header") doesn’t find _header.html.pug it will automatically search for _header.html.php and will use it as is, without passing through any compilation process.

Conclusions

As you can see, Wordless does not force you that much. Moreover, you will continue to have its goodies/helpers to break down views in little partials, simplifying code readability and organization.