PHPackages                             hypejunction/elgg-twig - 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. hypejunction/elgg-twig

ActiveElgg-plugin[Templating &amp; Views](/categories/templating)

hypejunction/elgg-twig
======================

Twig Template Rendering for Elgg

1.0.0(7y ago)023GPL-2.0PHPPHP &gt;=7.0

Since Feb 14Pushed 7y ago1 watchersCompare

[ Source](https://github.com/hypeJunction/elgg-twig)[ Packagist](https://packagist.org/packages/hypejunction/elgg-twig)[ Docs](http://hypejunction.com)[ RSS](/packages/hypejunction-elgg-twig/feed)WikiDiscussions master Synced 1mo ago

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

Twig Templates for Elgg
=======================

[](#twig-templates-for-elgg)

[![Elgg 2.3](https://camo.githubusercontent.com/cfd1f9530e267f480ce207ec10333e3a5ffc64bd5e292306d6431ec406aee1d4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f456c67672d322e332e782d6f72616e67652e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/cfd1f9530e267f480ce207ec10333e3a5ffc64bd5e292306d6431ec406aee1d4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f456c67672d322e332e782d6f72616e67652e7376673f7374796c653d666c61742d737175617265)

Adds support for twig templates in Elgg

Using Templates
---------------

[](#using-templates)

To add a twig template, simply add a file with `.twig` extension into your plugin's views, under `default` viewtype.

```

Hello, {{ name }}
```

To render a template use ``elgg\_twig()`with or without a view name without`.twig` extension:

```
$user = elgg_get_logged_in_user_entity();

echo elgg_twig('test', ['name' => $user->getDispayName()];
```

You can override templates like any other view, but you can not extend them or filter them using hooks.

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

[](#development)

To simplify development, set `environment` config value to `development`, otherwise you need to flush caches to reload template changes.

```
elgg_set_config('environment', 'development');
```

Globals
-------

[](#globals)

Globals available in templates

- `app` - application data
    - `app.user` - logged in user entity
    - `app.site` - site entity
    - `app.registrationUrl` - registration URL
    - `app.loginUrl` - login URL

Functions
---------

[](#functions)

Function available in templates

- `echo()` - equivalent of `elgg_echo()`
- `view()` - equivalent of `elgg_view()`
- `assetUrl()` - equivalent of `elgg_get_simplecache_url()`
- `requireJs()` - equivalent of `elgg_require_js()`

Notes
-----

[](#notes)

I have initially taught `elgg_view()` to render twig templates, but it had a negative performance impact, likely because of a `view_vars` hook registered for all views. Until there is a wildcard hook registration, `elgg_twig()` is the way to go, however it does not allow view vars to be filtered or views to be extended, which in the end is somewhat a win, because of simplicity.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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

Unknown

Total

1

Last Release

2641d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/5071b1cd852e094b3f564962a625e04c227adc73af30c5b46b243ab8f20154a7?d=identicon)[hypeJunction](/maintainers/hypeJunction)

---

Top Contributors

[![hypeJunction](https://avatars.githubusercontent.com/u/1202761?v=4)](https://github.com/hypeJunction "hypeJunction (2 commits)")

---

Tags

plugintwigelggtemplates

### Embed Badge

![Health badge](/badges/hypejunction-elgg-twig/health.svg)

```
[![Health](https://phpackages.com/badges/hypejunction-elgg-twig/health.svg)](https://phpackages.com/packages/hypejunction-elgg-twig)
```

###  Alternatives

[twig/extra-bundle

A Symfony bundle for extra Twig extensions

91292.0M313](/packages/twig-extra-bundle)[twig/intl-extra

A Twig extension for Intl

36663.2M218](/packages/twig-intl-extra)[twig/string-extra

A Twig extension for Symfony String

21946.0M132](/packages/twig-string-extra)[twig/cssinliner-extra

A Twig extension to allow inlining CSS

23018.5M53](/packages/twig-cssinliner-extra)[symfony/ux-twig-component

Twig components for Symfony

21814.8M161](/packages/symfony-ux-twig-component)[shoot/shoot

Shoot aims to make providing data to your templates more manageable

41229.9k2](/packages/shoot-shoot)

PHPackages © 2026

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