An open API service indexing awesome lists of open source software.

https://github.com/esase/tiny-view

The simple template engine for representation of your html code.
https://github.com/esase/tiny-view

esase framework html layout lightweight microservices renderer templateengine tinyframework view

Last synced: 3 months ago
JSON representation

The simple template engine for representation of your html code.

Awesome Lists containing this project

README

          

# tiny-view

[![Build Status](https://travis-ci.com/esase/tiny-view.svg?branch=master)](https://travis-ci.com/github/esase/tiny-view/builds)
[![Coverage Status](https://coveralls.io/repos/github/esase/tiny-view/badge.svg?branch=master)](https://coveralls.io/github/esase/tiny-view?branch=master)

**Tiny/View** separates your business logic from its representation, it means you can store your `view` as a list of
separated `.phtml` files and pass there you data keeping you controllers clean.

The package is very small and fast due to using native `php` inside templates and layouts, yes we don't use
any extra markup language, it's only relies on the php's [alternative syntax](https://www.php.net/control-structures.alternative-syntax)

There are only two main entities: `templates` and `layouts`.

`Templates` are used for displaying small peaces of information like list of users, a login form, etc. And the `layouts` which
work as wrappers for those templates. For instance you can have several layouts with already included `css` and `js` files and
It makes you life easier because you don't need to specify any `js` and `css` files for every template.

## Template

```php
[ // an array of users
['id' => 1, 'name' => 'Tester1'],
['id' => 2, 'name' => 'Tester2']
]],
'./users.phtml', // a template for the data,
'./layout/base.phtml' // a layout it's optional
);

// render the template using passed variables and wrap its content to a layout
echo $view;

```

```html


    users as $user): ?>

  • = $this->id ?>: = $this->name ?>



```

## Layout

```html




My test site




= $this->content ?>



```

## View helpers

When it's not enough a pre built functionality or it might be not convenient way to work with templates
you can register you own list of helpers (small functions) which will do exactly you want. Please read more information in the documentation

## Installation

Run the following to install this library:

```bash
$ composer require esase/tiny-view
```

## Documentation

https://tiny-docs.readthedocs.io/en/latest/tiny-view/docs/index.html