MOON
Server: Apache
System: Linux server1.studioinfinity.com.br 2.6.32-954.3.5.lve1.4.90.el6.x86_64 #1 SMP Tue Feb 21 12:26:30 UTC 2023 x86_64
User: artinside (517)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: /home/artinside/www/lhh/vendor/league/plates/doc/simple-example.md
---
layout: default
permalink: simple-example/
title: Simple example
---

Simple example
==============

Here is a simple example of how to use Plates. We will assume the following directory stucture:

~~~
`-- path
    `-- to
        `-- templates
            |-- template.phtml
            |-- profile.phtml
~~~

## Render a template

~~~ php
// Create new Plates instance
$templates = League\Plates\Engine::create('/path/to/templates');

// Render a template with the given data
echo $templates->render('profile', ['name' => 'Jonathan']);
~~~

## The page template

<div class="filename">profile.phtml</div>
~~~ php
<?php $v->layout('template', ['title' => 'User Profile']) ?>

<h1>User Profile</h1>
<p>Hello, <?=$v($name) // escape the $name variable ?></p>
~~~

## The layout template

<div class="filename">template.phtml</div>
~~~ php
<html>
<head>
    <title><?=$v($title)?></title>
</head>
<body>

<?=$v->section('content')?>

</body>
</html>
~~~