PHPackages                             jaypha/j-plate - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. jaypha/j-plate

ActiveLibrary[Templating &amp; Views](/categories/templating)

jaypha/j-plate
==============

Hierarchical components incorporating a PHP based template engine

v2.1.0(8y ago)0941BSL-1.0PHPPHP ^5.4 || ^7

Since Nov 5Pushed 8y agoCompare

[ Source](https://github.com/jaypha/j-plate)[ Packagist](https://packagist.org/packages/jaypha/j-plate)[ RSS](/packages/jaypha-j-plate/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (1)Versions (8)Used By (1)

Jaypha Templates
================

[](#jaypha-templates)

Written by Jason den Dulk

A simple, yet powerful template engine.

### Features

[](#features)

- Uses PHP itself as the template engine, so no need to reinvent the wheel or use bloated parsers and interpreters, or learn yet another language.
- You can create custom component classes that allow you to have extra component specific business logic that can be kept out of the template, or handle boilerplate you dont want to have repeated in every template file.
- Specify the template either as a string or a file.
- Direct output. Displays content directly to output for faster rendering. Output to a string (via `__toString`) is also supported.
- Hierarchical. Components can be added to other Components to create output of arbitrary complexity. No need for partials, layouts or helpers as `Component` can be used for all of these roles.

Requirements
------------

[](#requirements)

PHP v5.4.0 or greater.

Installation
------------

[](#installation)

```
composer require jaypha/j-plate

```

API
---

[](#api)

### class Component

[](#class-component)

`__construct($template, $initialData)`

Constructor for the `Component` class.
`$template` - The template file to use.
`$initialData` - Associative array for values to be used. May be non-associative if no template is provided.

`void setTemplate(string $template = null)`Sets the template file

`void setVars(array $values)`Sets all the values.

`void set(string $name, mixed $value)`Sets a single value

`void remove(string $name)`Removes a value stored under $name.

`void add(mixed $value)`Adds a value without a name. Useful when no template is being used.

`void clear()`Removes all values.

`void display()`Outputs the contents to the output context.

`string __toString()`Returns the contents as a string.

#### trait TextComponentTrait

[](#trait-textcomponenttrait)

A trait that allows the template to be provided directly instead of via a file.

#### class TextComponent

[](#class-textcomponent)

Behaves the same as `Component` except that the template is provided directly instead of via a file.

How to use templates
--------------------

[](#how-to-use-templates)

This project make use of PHP's ability to embed PHP code inside a text file. Simply surround your code with ``, or ``.

All values are loaded into the context and can be accessed directly. For example, a value set with the name `viewName`, can be printed with ``.

License
-------

[](#license)

Copyright (C) 2017 Jaypha.
Distributed under the Boost Software License, Version 1.0.
See [http://www.boost.org/LICENSE\_1\_0.txt](http://www.boost.org/LICENSE_1_0.txt)

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity63

Established project with proven stability

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~25 days

Recently: every ~16 days

Total

7

Last Release

3006d ago

Major Versions

v1.0.1 → v2.0.02018-01-31

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1052990?v=4)[Jason den Dulk](/maintainers/jaypha)[@jaypha](https://github.com/jaypha)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jaypha-j-plate/health.svg)

```
[![Health](https://phpackages.com/badges/jaypha-j-plate/health.svg)](https://phpackages.com/packages/jaypha-j-plate)
```

###  Alternatives

[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3861.2M](/packages/limenius-react-bundle)[area17/laravel-auto-head-tags

Laravel Auto Head Tags helps you build the list of head elements for your app

4616.0k](/packages/area17-laravel-auto-head-tags)[jelix/wikirenderer

WikiRenderer is a library to generate HTML or anything else from wiki content.

1712.2k1](/packages/jelix-wikirenderer)[webkinder/sproutset

A Composer package for handling responsive images in Roots Bedrock + Sage + Blade projects.

281.8k](/packages/webkinder-sproutset)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
