PHPackages                             manychois/views - 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. manychois/views

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

manychois/views
===============

A naive PHP template library

2.1.0(3y ago)1941MITPHPPHP &gt;=8CI failing

Since Jun 26Pushed 1y ago1 watchersCompare

[ Source](https://github.com/manychois/php-views)[ Packagist](https://packagist.org/packages/manychois/views)[ RSS](/packages/manychois-views/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (5)Versions (7)Used By (1)

Manychois\\Views
================

[](#manychoisviews)

A naive PHP template library. Version 2 is a complete rewrite.

How to use
----------

[](#how-to-use)

Extend `Manychois\Views\AbstractView` and define your template in `body()` function. Use `$this->inner()` or `$this->region()` to set where you would like child content to be injected. For child template, override `getParentViewClass()` to inform this library its parent class name.

Then you can use `AbstractView::render($templateClassName, $viewData)` for rendering.

The `tests/` folder contains some example usages of `AbstractView`.

### Utility

[](#utility)

There are a few classes to help you generate HTML.

#### `Manychois\Views\Esc`

[](#manychoisviewsesc)

It contains 5 methods to escape string in different contexts.

- `attr(string $text, bool $unquoted = false)`
- `css(string $text)`
- `html(string $text)`
- `js(string $text, bool $templateMode = false)`
- `url(string $text)`

#### `Manychois\Views\ResourceLibrary`

[](#manychoisviewsresourcelibrary)

It is used to manage stylesheet / script dependencies.

```
