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 7y 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 3d 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 49% 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

2960d ago

Major Versions

v1.0.1 → v2.0.02018-01-31

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ca39c239f426fd20c6348188dc7cf2b2ff3783ebb5d44bd886572a8ec53b24f?d=identicon)[jaypha](/maintainers/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

[mustache/mustache

A Mustache implementation in PHP.

3.3k44.6M291](/packages/mustache-mustache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[nicmart/string-template

StringTemplate is a very simple string template engine for php. I've written it to have a thing like sprintf, but with named and nested substutions.

2101.7M30](/packages/nicmart-string-template)

PHPackages © 2026

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