wherd/signal

Yet another template engine

Maintainers

Details

github.com/wherd/signal

Source

Issues

Fund package maintenance!
Other

v1.04 2022-05-16 07:23 UTC

This package is auto-updated.

Last update: 2022-05-16 07:24:45 UTC


README

Yet another template engine.

Installation

Install using composer:

composer require wherd/signal

Usage

Create a signal instance by passing it the folder(s) where your view files are located. Render a template by calling the render method.

use Wherd\Signal\Engine;

$signal = new Engine(__DIR__ . '/views');
$signal->setCacheDirectory(__DIR__ . '/tmp');

echo $signal->render('homepage', ['name' => 'John Doe']);

You can also extend Singal using the directive() function:

$signal->directive(
  'datetime',
  fn ($expression) => "<?php echo (new DateTime($expression))->format('F d, Y g:i a'); ?>"
);

Which allows you to use the following in your signal template:

Current date: @datetime($date)