Requirements

Installation

Install Nate via Composer:

composer require thenlabs/nate

If you want the latest development version:

composer require thenlabs/nate dev-main

Basic Usage

Create a template file (e.g., hello.tpl.php):

<!DOCTYPE html>
<html>
<head>
    <title><?= $this->title ?></title>
</head>
<body>
    <h1>Hello, <?= $this->name ?>!</h1>
    <p><?= $this->message ?></p>
</body>
</html>

Note: Inside templates, $this refers to the Compiler instance. Accessing $this->variableName retrieves a variable from the data passed to render().

Render the template in your PHP code:

<?php
require_once 'vendor/autoload.php';

use ThenLabs\Nate\Template;

$template = new Template('/path/to/hello.tpl.php');

echo $template->render([
    'title'   => 'My Page',
    'name'    => 'World',
    'message' => 'Welcome to Nate!',
]);

Output:

<!DOCTYPE html>
<html>
<head>
    <title>My Page</title>
</head>
<body>
    <h1>Hello, World!</h1>
    <p>Welcome to Nate!</p>
</body>
</html>

Template File Extensions

Nate does not enforce a specific file extension. You can use any of the following:

Tip: Using a distinct extension like .tpl.php helps your IDE apply the right syntax highlighting and keeps templates easily identifiable.