https://github.com/inanepain/view
View layer with models for most common of content types.
https://github.com/inanepain/view
inane library php view
Last synced: 3 months ago
JSON representation
View layer with models for most common of content types.
- Host: GitHub
- URL: https://github.com/inanepain/view
- Owner: inanepain
- License: unlicense
- Created: 2022-04-10T09:38:56.000Z (about 3 years ago)
- Default Branch: develop
- Last Pushed: 2023-01-24T15:59:41.000Z (over 2 years ago)
- Last Synced: 2025-02-03T21:53:38.722Z (4 months ago)
- Topics: inane, library, php, view
- Language: PHP
- Homepage:
- Size: 23.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Readme: View
> $Id$ ($Date$)
View layer with models for most common of content types.
## Install
`composer require inanepain/view`
## Usage
Currently only two renderers are available:
- PhpRenderer
- StringRenderer### Php Renderer
By far the more functional of the two, the PhpRenderer uses php files as templates. Any php code within the templates runs as expected.
The optional `$thisObject` parameter can be accessed inside the template as `$this`.**example:**
```php
// TODO: PhpRenderer example
```### String Renderer
This basic renderer completes string templates replacing the variable placeholder `{$name}` with the value from the `$data` array.
Everything else is treated as text, the template will not by run as code even if it is code.**example:**
```php
$data = [
'label' => ['label' => 'Inane Website'],
'a' => ['title' => 'Inane', 'url' => 'https://inane.co.za'],
];$sr = new StringRenderer([
'label' => '{$label}',
'a' => '{$title}',
]);echo $sr->render('label', $data['label'], true) . PHP_EOL;
echo $sr->render('a', $data['a'], true) . PHP_EOL;echo $sr->render('label', ['label' => 'Google'], true) . PHP_EOL;
echo $sr->render('a', ['title' => 'SA', 'url' => 'https://www.google.co.za'], true) . PHP_EOL;
echo $sr->render('a', ['title' => 'International', 'url' => 'https://www.google.com'], true) . PHP_EOL;echo $sr->render('
{$heading}
', ['heading' => 'Bob'], false) . PHP_EOL;
```