Wallogit.com
2017 © Pedro Peláez
Gaunt is the simplest template engine written for Wordpress. The engine is heavily inspired and based upon Laravel 4 Blade. Gaunt is not nearly as heavy and feature-rich as dedicated template engines such as Smarty and Twig. But it helps you simplify your theme pages quite a lot., (*1)
Gaunt is installable through Composer., (*2)
"require" : {
"gaunt/gaunt":"1.0.*"
}
Require "vendor/autoload.php" in your functions.php or plugin.php, (*3)
require("vendor/autoload.php");
@startloop
``the_title();``
``the_content();``
@endloop
@startloop
``the_title();``
``the_content();``
@noposts
No posts yet, sorry.., (*4)
@endloop
Code blocks is equal to , (*5)
``
$foo = "bar";
$bar = ["a","b","c"];
``
Hello, {{ $user }}.
Hello, {{ $user.name }} // $user['name'];
Hello, {{ $user->name }}
The current UNIX timestamp is {{ time() }}.
@if (count($posts) === 1)
I have one post!
@elseif (count($posts) > 1)
I have multiple posts!
@else
I don't have any posts!
@endif
@for ($i = 0; $i < 10; $i++)
The current value is {{ $i }}
@endfor
@foreach ($posts as $post)
The title of this post is: {{ $post->post_title }}, (*6)
@endforeach
@while (true)
I'm looping forever., (*7)
@endwhile
@include('view.php')
{{-- This comment will not be in the rendered HTML --}}
<!doctype html>
<html lang="en">
<head>
<title>Page Title</title>
</head>
<body>
@include('header.php')
@startloop
``the_title();``
``the_content();``
@noposts
<p>Sorry no posts here..</p>
@endloop
@include('footer.php')
</body>
</html>