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
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()
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 :)
Rename
_header.html.pug
in_header.html.php
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>
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.