But what can we do with this template engine? Well… Besides the fact that it’s faster to work with it, it is also safer (or at least “they say” it is).

Let’s now see how or HomepageView.php looks like:

App/Views/HomepageView.php

PHP

1

2

3

4

<?php

echo'hello from index'.'<br />';

echo'<a href="'.$url.'">'.$name.'</a>';

And how we can make it look lighter by using the templating engine:

App/Views/HomepageView.php

PHP

1

2

<p>hello from index</p>

<p><ahref="{{ @url }}">{{@name}}</a></p>

Wow… Much shorter…

What is nice about the templating engine is the fact that it can use hive‘s variables directly and not by passing the values to an intermediary variable. If we return to our Homepage.php controller we can do something as follows: