Book Image

FuelPHP Application Development Blueprints

By : Sebastien Drouyer
Book Image

FuelPHP Application Development Blueprints

By: Sebastien Drouyer

Overview of this book

Table of Contents (13 chapters)
FuelPHP Application Development Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

The Parser package and template engines


You may notice that we added the parser package into the always_load.package key. Thanks to this package, instead of writing our view in PHP, we are able to use template engines. For those of you that are not familiar with template engines, they allows us to write our view files in a different syntax.

For instance, a list of items might be displayed by writing the following code in PHP:

<h1>Items</h1>
<?php foreach ($items as $item) { ?>
    <li><?php echo $item->title ?></li>
<?php } ?>
<a href="item/create">Create an item</a>

But, using the HAML template engine, it can be written like this:

%h1 Items
- foreach ($items as $item)
  %li
    = $item->title
%a(href="item/create") Create an item

Alternatively, by using the Mustache template engine, it can be written like this:

<h1>Items</h1>
{{#items}}
  <li>{{title}}</li>
{{/items}}
<a href="item/create">Create an item...