This package is abandoned and no longer maintained. No replacement package was suggested.
There is no license information available for the latest version (dev-master) of this package.

A Twig powered WordPress template builder.

dev-master 2013-03-18 04:33 UTC

This package is auto-updated.

Last update: 2022-02-01 12:23:22 UTC


#Ink WordPress Starter Theme

##What is Ink? Ink is a WordPress starter theme that harnesses the power of the Twig template engine to build readable WordPress templates.

##Why Ink? First, and foremost, PHP is not a template engine! If you would like to disagree, please read this blog before arguing.

"If you think PHP is still a template language, can you give me just one recent change in the PHP language which enhanced PHP as a template language? I cannot think of one."

PHP is a dynamic language that started its life as a template engine, but has grown into a powerful, community-orientated language. PHP is no longer a templating language. Smarty, Django, HAML and Twig are templating languages.

##If you decide to use Ink, you are not stuck with Twig. This is, by no means, and exhaustive replacement for traditional WordPress templates. If there is something that Ink cannot (yet) do that PHP does, you can still use a normal template file.

##Installing Ink Get Composer composer.phar install badcow/ink

##Compare Twig to PHP Below we will compare two files that both achieve the same thing; they both render a page and list other pages. The first example uses Twig, the second uses PHP.

###Twig syntax

{% extends 'base.html.twig' %}

{% block content %}
    <h1>{{ post.title }}</h1>
    <em>{{'d/m/Y') }}</em><br />
    {{ post.content }}

    <h1>List of posts</h1>

    {% set posts = postQuery.getPosts('post_type=page') %}

    {%for posty in posts %}
        {{posty.content | raw}}
        <hr />
    {% else %}
        <em>There are no posts to be displayed, sorry.</em>
    {% endfor %}

{% endblock %}

###PHP syntax

<?php get_header(); ?>

    <h1><?php the_title(); ?></h1>

    <?php the_date('d/m/Y', '<em>', '</em>'); ?><br />

    <?php the_content(); ?>

    <h1>List of posts</h1>

        $posts = new WP_Query('post_type=page');
            while($posts->have_posts()): $posts->the_post();

                <h2><?php the_title(); ?></h2>
                <?php the_content(); ?>
                <hr />
            <?php endwhile; ?>
        <?php else: ?>
            <em>There are no posts to be displayed, sorry.</em>
        <?php endif; ?>


<?php get_footer(); ?>

The advantage of Twig is that the syntax is more fluid and is closer to HTML than to PHP. In templating using PHP, it becomes a monstrous task to keep track of all the loop beginnings and endings.