PHPackages                             spindle/view - 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. spindle/view

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

spindle/view
============

simple layout renderer

1.0.3(11y ago)310511CC0-1.0PHPPHP &gt;=5.3.2

Since May 2Pushed 10y agoCompare

[ Source](https://github.com/spindle/spindle-view)[ Packagist](https://packagist.org/packages/spindle/view)[ RSS](/packages/spindle-view/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (1)Dependencies (3)Versions (6)Used By (1)

spindle/view
============

[](#spindleview)

[![Build Status](https://camo.githubusercontent.com/948a1390145418c8bd9b85449c98276440070843aa38966b4dafddd3680dadc2/68747470733a2f2f7472617669732d63692e6f72672f7370696e646c652f7370696e646c652d766965772e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/spindle/spindle-view)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/c46e96c2021fa9e445977c31631b075bea112c5205fd34695c8231302dd34456/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696e646c652f7370696e646c652d766965772f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/spindle/spindle-view/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/25e826d98b11073442d89a634aa065c5b54ae010964e166c48cb6ee42ee2d6a9/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f7370696e646c652f7370696e646c652d766965772f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/spindle/spindle-view/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/0b9abce6d2c94d28bd5136ebc21bf1ae1ab43938b6a4e2b46da2096c25913881/68747470733a2f2f706f7365722e707567782e6f72672f7370696e646c652f766965772f762f737461626c652e706e67)](https://packagist.org/packages/spindle/view)[![Total Downloads](https://camo.githubusercontent.com/452f128c9a097c869eb931f476f5de6aa647c49294056cfa01f50a477261f43e/68747470733a2f2f706f7365722e707567782e6f72672f7370696e646c652f766965772f646f776e6c6f6164732e706e67)](https://packagist.org/packages/spindle/view)[![Latest Unstable Version](https://camo.githubusercontent.com/e4cde14d5e4767ad5960ff3503bda851c876c912b23deba674f0fdfb9f625bfd/68747470733a2f2f706f7365722e707567782e6f72672f7370696e646c652f766965772f762f756e737461626c652e706e67)](https://packagist.org/packages/spindle/view)[![License](https://camo.githubusercontent.com/e12519ba5c1b0f40ab5aaa6150187657fc1547090dad67b20a9db80e7b026a3c/68747470733a2f2f706f7365722e707567782e6f72672f7370696e646c652f766965772f6c6963656e73652e706e67)](https://packagist.org/packages/spindle/view)

素のPHPをテンプレートエンジンとして使う際、レイアウト構造を実現するライブラリです。 1つのクラスだけの非常に小さなライブラリですが、"継承"機能をほぼ網羅しています。

自動エスケープなどの機能はありませんが、最低限のエスケープ機能はhelperとして実装してあります。

インストールには[composer](https://getcomposer.org/)が使えます。

```
$ composer require "spindle/view:*"
```

バージョン1.0.2より、GitHubのzip-archiveには最小限のソースコードのみ含まれるようにしています。 testやexampleが必要な場合はこのリポジトリを参照するか、--prefer-sourceオプションを使ってください。

```
$ composer require "spindle/view:*" --prefer-source
```

使い方
---

[](#使い方)

クラス一つだけなので、require\_onceで読み込むこともできますし、composerでオートロードしても構いません。

### 1. シンプルな例

[](#1-シンプルな例)

`template.phtml`は素のPHPで書かれたテンプレートファイルとします。 $titleと$mainを埋めるとHTMLの文字列が完成します。

```

```

これをHTML化するには、以下のようなスクリプトを書きます。

```
