PHPackages                             kaiseki/wp-template-renderer - 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. kaiseki/wp-template-renderer

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

kaiseki/wp-template-renderer
============================

Render WordPress template parts by slug or from a class, with a configurable class-to-slug generator

1.0.0(1mo ago)0430MITPHPPHP ^8.2

Since Jun 3Pushed 3w ago2 watchersCompare

[ Source](https://github.com/kaisekidev/kaiseki-wp-template-renderer)[ Packagist](https://packagist.org/packages/kaiseki/wp-template-renderer)[ Docs](https://github.com/kaisekidev/kaiseki-wp-template-renderer)[ RSS](/packages/kaiseki-wp-template-renderer/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (15)Versions (3)Used By (0)

kaiseki/wp-template-renderer
============================

[](#kaisekiwp-template-renderer)

Render WordPress template parts by slug or from a class, with a configurable class-to-slug generator.

Two renderers, both wired through `ConfigProvider`:

- **`TemplateRenderer`** — renders a template part by slug from a configurable base directory under the active theme (default `template-parts`), capturing its output as a string.
- **`ClassTemplateRenderer`** — renders a template part that lives next to a given object's class file, deriving the slug from the class short name (kebab-cased by default) via a `ClassSlugGeneratorInterface`.

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

[](#installation)

```
composer require kaiseki/wp-template-renderer
```

Requires PHP 8.2 or newer.

Usage
-----

[](#usage)

Register `ConfigProvider` with your laminas-style config aggregator. It declares the renderer factories and aliases `ClassSlugGeneratorInterface` to the kebab-case `ClassTemplateSlugGenerator`, and exposes a `template_renderer` config key for the defaults:

```
use Kaiseki\WordPress\TemplateRenderer\ConfigProvider;

return (new ConfigProvider())();
// [
//     'template_renderer' => [
//         'template_renderer'       => ['template_directory' => 'template-parts'],
//         'class_template_renderer' => ['template_name' => 'template'],
//     ],
//     'dependencies' => [ /* aliases + factories */ ],
//     'hook'         => ['provider' => []],
// ]
```

### Rendering a template part by slug

[](#rendering-a-template-part-by-slug)

```
use Kaiseki\WordPress\TemplateRenderer\TemplateRenderer;

/** @var TemplateRenderer $renderer */
$renderer = $container->get(TemplateRenderer::class);

// Renders /template-parts/card.php and returns its output.
$html = $renderer->render('card', ['title' => 'Hello']);

// With a name variant: /template-parts/card-featured.php
$html = $renderer->render('card', ['title' => 'Hello'], 'featured');
```

The base directory is configurable via `template_renderer.template_renderer.template_directory`.

### Rendering a template part from a class

[](#rendering-a-template-part-from-a-class)

```
use Kaiseki\WordPress\TemplateRenderer\ClassTemplateRenderer;

/** @var ClassTemplateRenderer $renderer */
$renderer = $container->get(ClassTemplateRenderer::class);

// For an instance of App\Blocks\HeroBlock, looks for hero-block-template.php
// next to HeroBlock's class file and returns its output.
$html = $renderer->render($block, ['heading' => 'Welcome']);

// Override the derived slug and/or the template name suffix:
$html = $renderer->render($block, ['heading' => 'Welcome'], slug: 'hero', templateName: '');
```

The slug is produced by the `ClassSlugGeneratorInterface` binding (kebab-cased class short name by default); the template-name suffix defaults to `template_renderer.class_template_renderer.template_name`.

Both renderers throw a `RuntimeException` when the resolved template file does not exist.

Development
-----------

[](#development)

```
composer install
composer check   # check-deps, cs-check, phpstan
```

License
-------

[](#license)

MIT — see [LICENSE](LICENSE.md).

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance95

Actively maintained with recent releases

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 66.7% of commits — single point of failure

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

Unknown

Total

1

Last Release

30d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1c3a6b11aea9668c9e9ca0c0f8515ef114d344acb552c695d715d35d5b388ea4?d=identicon)[woda](/maintainers/woda)

---

Top Contributors

[![davidmondok](https://avatars.githubusercontent.com/u/3883758?v=4)](https://github.com/davidmondok "davidmondok (2 commits)")[![developeratexample](https://avatars.githubusercontent.com/u/14004359?v=4)](https://github.com/developeratexample "developeratexample (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/kaiseki-wp-template-renderer/health.svg)

```
[![Health](https://phpackages.com/badges/kaiseki-wp-template-renderer/health.svg)](https://phpackages.com/packages/kaiseki-wp-template-renderer)
```

###  Alternatives

[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[symfony/dependency-injection

Allows you to standardize and centralize the way objects are constructed in your application

4.2k455.6M9.6k](/packages/symfony-dependency-injection)[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k51.2M339](/packages/api-platform-core)[moonshine/moonshine

Laravel administration panel

1.3k253.1k81](/packages/moonshine-moonshine)[ecotone/ecotone

Enterprise architecture layer for Laravel and Symfony — CQRS, Event Sourcing, Durable Workflows (Sagas, Orchestrators), Projections, and Outbox messaging via PHP attributes.

564576.7k53](/packages/ecotone-ecotone)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)

PHPackages © 2026

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