PHPackages                             seanmorris/theme - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. seanmorris/theme

ActiveLibrary[Templating &amp; Views](/categories/templating)

seanmorris/theme
================

Simple, sane templating and theming for PHP

1.0.8(4y ago)03.5kApache-2.0PHP

Since Feb 14Pushed 4y ago1 watchersCompare

[ Source](https://github.com/seanmorris/theme)[ Packagist](https://packagist.org/packages/seanmorris/theme)[ RSS](/packages/seanmorris-theme/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (10)Used By (0)

SeanMorris\\Theme
=================

[](#seanmorristheme)

Simple, sane templating and theming for PHP
-------------------------------------------

[](#simple-sane-templating-and-theming-for-php)

[![Build Status](https://camo.githubusercontent.com/d53a49cc925eff45b5bed390e28c1406448ab1475142532090050dc892ed707e/68747470733a2f2f7472617669732d63692e6f72672f7365616e6d6f727269732f7468656d652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/seanmorris/theme) [![Latest Stable Version](https://camo.githubusercontent.com/e4df3f3dfcb9112f1209ee1c334af9b63d8204d90fd51a058a48502ecc7411f2/68747470733a2f2f706f7365722e707567782e6f72672f7365616e6d6f727269732f7468656d652f762f737461626c65)](https://packagist.org/packages/seanmorris/theme) [![Total Downloads](https://camo.githubusercontent.com/c27708d2a85415104a90b4b698cd7f87ffb6b493e9b4a814b02ae189ef87a4f9/68747470733a2f2f706f7365722e707567782e6f72672f7365616e6d6f727269732f7468656d652f646f776e6c6f616473)](https://packagist.org/packages/seanmorris/theme) [![Latest Unstable Version](https://camo.githubusercontent.com/d52ccf288479dd7317672dea66ddcf5ebeb0ca81c8d45e186b68b81b24855700/68747470733a2f2f706f7365722e707567782e6f72672f7365616e6d6f727269732f7468656d652f762f756e737461626c65)](https://packagist.org/packages/seanmorris/theme) [![License](https://camo.githubusercontent.com/13d7dc9ad10265ad44a7be101eb1fbcb24cb162372b1e59d3582b5071be326d8/68747470733a2f2f706f7365722e707567782e6f72672f7365616e6d6f727269732f7468656d652f6c6963656e7365)](https://packagist.org/packages/seanmorris/theme)

The aim of the Theme library is to provide a start separation of presentation from logic. It has only two responsibilities:

- Mapping objects to Views
- Rendering those Views

Composer
--------

[](#composer)

Just run `composer require seanmorris/theme` in your project directory.

You can also add `"seanmorris/theme": "^1.0.0"` to the `require` array in your project's composer.json.

```
"require": {
  "seanmorris/theme": "^1.0.0"
}
```

Templating
----------

[](#templating)

Coupling the template with the View class is very simple. Simply subclass the provided View and append the template after a call to `__halt_compiler();` (WITH THE CLOSING `?>`) like so:

(note: Short tags are enabled for simple echo statements as of PHP 5.4, but are not required)

```

FooView

.
```

Pass an associative array into the constructor to populate the variables in the template. The keys of the array will be translated to variable names.

```
