PHPackages                             getolympus/olympus-hera-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. getolympus/olympus-hera-renderer

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

getolympus/olympus-hera-renderer
================================

Olympus Hera is a bundle used to render all components views through the TWIG template engine.

v0.0.6(6y ago)02653MITPHP

Since Mar 1Pushed 6y ago1 watchersCompare

[ Source](https://github.com/GetOlympus/Hera-Renderer)[ Packagist](https://packagist.org/packages/getolympus/olympus-hera-renderer)[ Docs](https://github.com/GetOlympus/Hera-Renderer)[ RSS](/packages/getolympus-olympus-hera-renderer/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (7)Used By (3)

Olympus Hera Renderer
=====================

[](#olympus-hera-renderer)

> **Olympus Hera Renderer** is a bundle used to render all components views through the TWIG template engine.

```
composer require getolympus/olympus-hera-renderer
```

---

[![Olympus Component](https://camo.githubusercontent.com/f483886a465a9e44005a352c6c1ba6556689a579ecf0d8b984cf60becaaa878c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f666f722d4f6c796d7075732d3434636331312e7376673f7374796c653d666c61742d737175617265)](https://github.com/GetOlympus)[![CodeFactor Grade](https://camo.githubusercontent.com/fd8a8bda4a56b1c31452be6fd21ef802b4f9e7d832f9b5b52033293260c7018e/68747470733a2f2f7777772e636f6465666163746f722e696f2f7265706f7369746f72792f6769746875622f4765744f6c796d7075732f486572612d52656e64657265722f62616467653f7374796c653d666c61742d737175617265)](https://www.codefactor.io/repository/github/getolympus/Hera-Renderer)[![Packagist Version](https://camo.githubusercontent.com/04de03409f0100d3bc3028b4c6d28f9e4b724092e6f36e43bdd42d124b5971d0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6765746f6c796d7075732f6f6c796d7075732d486572612d52656e64657265722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/getolympus/olympus-Hera-Renderer)[![MIT](https://camo.githubusercontent.com/68035de4b7f69ada20e98e34172f47d361b83a017c8045200fc338660c467897/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49545f4c6963656e73652d626c75652e7376673f7374796c653d666c61742d737175617265)](https://github.com/GetOlympus/Hera-Renderer/blob/master/LICENSE)

---

Example
-------

[](#example)

You can easily use the `Hera` renderer to display TWIG template:

```
namespace MyCustomPackage;

use GetOlympus\Hera\Hera;

class MyPackage
{
    protected function displayContent()
    {
        /**
         * Sample extracted from the `Metabox` Zeus-Core component.
         * @see https://github.com/GetOlympus/Zeus-Core/blob/master/src/Zeus/Metabox/Metabox.php
         */

        // Prepare admin scripts and styles
        $assets = [
            'scripts' => [],
            'styles'  => [],
        ];

        $vars = [];

        // Display fields
        foreach ($fields as $field) {
            if (!$field) {
                continue;
            }

            // Update scripts and styles
            $fieldassets = $field->assets();

            if (!empty($fieldassets)) {
                $assets['scripts'] = array_merge($assets['scripts'], $fieldassets['scripts']);
                $assets['styles']  = array_merge($assets['styles'], $fieldassets['styles']);
            }

            $vars['fields'][] = $field->prepare('metabox', $post, 'post');
        }

        /**
         * Outside the loop, you'll get an array with these elements:
         *
         * $vars = [
         *     'fields' => [
         *         [
         *             'context' => 'wordpress',
         *             'path' => '/path/to/resources/views',
         *             'template' => 'wordpress.html.twig',
         *             'vars' => [-- vars used in the target template --]
         *         ],
         *         [-- more and more --],
         *     ]
         * ];
         */

        // Render view
        $render = new Hera('core', 'layouts'.S.'metabox.html.twig', $vars, $assets);
        $render->view();
    }
}
```

Initialization
--------------

[](#initialization)

The `Hera` component needs to be initialized by this way:

```
/**
 * Constructor.
 *
 * @param  string  $context
 * @param  string  $template
 * @param  array   $vars
 * @param  array   $assets
 * @param  bool    $usecache
 */
new Hera($context, $template, $vars, $assets, $usecache);
```

VariableTypeDefault value if not setDetails`context`String*mandatory*Used by the TWIG template engine to retrieve wanted template`template`String*mandatory*TWIG template to load`vars`Array*mandatory*List of vars used in the TWIG loaded template`assets`Array`[]`List of assets files to load to render template`usecache`Boolean`false`Define wether to use or not TWIG engine cache systemCustomization
-------------

[](#customization)

If you need to add your custom TWIG functions, you can use the `ol_hera_render_functions` action hook:

```
add_action('ol.hera.render_functions', function ($twig) {
    // Example to use the WordPress `get_header()` function through TWIG: {{ get_header(file) }}
    $twig->addFunction(new \Twig\TwigFunction('get_header', function ($file = '') {
        get_header($file);
    }));
});
```

Release History
---------------

[](#release-history)

See [**CHANGELOG.md**](https://github.com/GetOlympus/Hera-Renderer/blob/master/CHANGELOG.md) for all details.

Contributing
------------

[](#contributing)

1. Fork it ()
2. Create your feature branch (`git checkout -b feature/fooBar`)
3. Commit your changes (`git commit -am 'Add some fooBar'`)
4. Push to the branch (`git push origin feature/fooBar`)
5. Create a new Pull Request

---

**Built with ♥ by [Achraf Chouk](http://github.com/crewstyle "Achraf Chouk") ~ (c) since a long time.**

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Every ~7 days

Total

5

Last Release

2232d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c255b14ebf8b792ba8b0c9940bd13e899281fc1431f1088af9074acdaa191cef?d=identicon)[crewstyle](/maintainers/crewstyle)

---

Top Contributors

[![crewstyle](https://avatars.githubusercontent.com/u/1572149?v=4)](https://github.com/crewstyle "crewstyle (16 commits)")

---

Tags

engineheraolympusolympus-bundlephprenderrenderertwigwordpressphpwordpresstwiglibrarytemplaterendererenginerenderolympusheraolympus-hera

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/getolympus-olympus-hera-renderer/health.svg)

```
[![Health](https://phpackages.com/badges/getolympus-olympus-hera-renderer/health.svg)](https://phpackages.com/packages/getolympus-olympus-hera-renderer)
```

PHPackages © 2026

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