Skip to content

lvinceslas/htmltemplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HtmlTemplate

Packagist Version PHP Version License

A simple template engine for PHP.

Installation

composer require lvinceslas/htmltemplate

Using Docker (without Composer installed locally)

docker run --rm -it \
  -v "$(pwd):/app" \
  -w /app \
  composer require lvinceslas/htmltemplate

Usage

Create an HTML template file with placeholders, for example:

Hello <b>{%NAME%}</b>, you have successfully installed <em>lvinceslas/htmltemplate</em>!

Then use it in PHP:

<?php

require __DIR__ . '/vendor/autoload.php';

use Lvinceslas\Html\HtmlTemplate;

$template = new HtmlTemplate(__DIR__ . '/path/to/template.html');
$template->set('NAME', 'John Doe');

// You can echo the object directly
echo $template;

// Or explicitly call show()
// $template->show();

Running the test suite

The unit tests are based on PHPUnit and can be executed via Docker:

docker run --rm -it \
  -v "$(pwd):/app" \
  -w /app \
  composer ./vendor/bin/phpunit

This command uses the phpunit.xml.dist configuration file located at the root of the project.

About

A simple template class

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published