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.

doctype html
  head= render_partial("layouts/head")
    .page-wrapper render_partial("layouts/header") wl_yield() 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()
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.


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.:

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


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.