Skip to content

Commit

Permalink
Merge pull request #101 from odan/badge
Browse files Browse the repository at this point in the history
Update badges
  • Loading branch information
odan authored Jul 10, 2024
2 parents c0f83e9 + fb203db commit c172b98
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
[![Build Status](https://travis-ci.org/geggleto/PHP-View.svg?branch=master)](https://travis-ci.org/geggleto/PHP-View)

[![Build Status](https://github.com/slimphp/PHP-View/actions/workflows/tests.yml/badge.svg?branch=3.x)](https://github.com/slimphp/PHP-View/actions)
[![Latest Stable Version](https://poser.pugx.org/slim/PHP-View/v)](https://packagist.org/packages/slim/PHP-View)
[![License](https://poser.pugx.org/slim/PHP-View/license)](https://packagist.org/packages/slim/PHP-View)

## PHP Renderer

Expand All @@ -14,8 +17,9 @@ Note that PHP-View has no built-in mitigation from XSS attacks. It is the develo

Install with [Composer](http://getcomposer.org):

composer require slim/php-view

```
composer require slim/php-view
```

## Usage with Slim 4

Expand All @@ -37,6 +41,7 @@ $app->run();
Note that you could place the PhpRenderer instantiation within your DI Container.

## Usage with any PSR-7 Project

```php
//Construct the View
$phpView = new PhpRenderer("path/to/templates");
Expand All @@ -63,6 +68,7 @@ $phpView->addAttribute($key, $value);
```

Data passed in via `->render()` takes precedence over attributes.

```php
$templateVariables = [
"title" => "Title"
Expand All @@ -78,7 +84,9 @@ $phpView->render($response, $template, [
```

## Sub-templates
Inside your templates you may use `$this` to refer to the PhpRenderer object to render sub-templates. If using a layout the `fetch()` method can be used instead of `render()` to avoid appling the layout to the sub-template.

Inside your templates you may use `$this` to refer to the PhpRenderer object to render sub-templates.
If using a layout the `fetch()` method can be used instead of `render()` to avoid appling the layout to the sub-template.

```phtml
<?=$this->fetch('./path/to/partial.phtml', ["name" => "John"])?>
Expand Down

0 comments on commit c172b98

Please sign in to comment.