PHPackages                             md/pug-slim - 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. md/pug-slim

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

md/pug-slim
===========

1.0(8y ago)71.1k2PHP

Since Jun 25Pushed 7y agoCompare

[ Source](https://github.com/MarcelloDuarte/pug-slim)[ Packagist](https://packagist.org/packages/md/pug-slim)[ RSS](/packages/md-pug-slim/feed)WikiDiscussions master Synced 2mo ago

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

Pug Renderer
------------

[](#pug-renderer)

This is a (heavily based on the [PhpRenderer](https://github.com/slimphp/PHP-View/blob/master/src/PhpRenderer.php)) renderer for rendering Pug view scripts into a PSR-7 Response object. It works well with Slim Framework 3.

### Security risks

[](#security-risks)

Pug Renderer uses [Pug.php](https://github.com/pug-php/pug) under the hood. Pug Renderer is merely a thin layer to Pug.php work with Slim 3. We will not keep track of vulnerabilities. Please refer to the original project to find out more how to prevent issues and to report vulnerabilities.

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

[](#installation)

Install with [Composer](http://getcomposer.org):

```
$ composer require md/pug-slim
```

Usage with Slim 3
-----------------

[](#usage-with-slim-3)

```
use Slim\Views\PugRenderer;

include "vendor/autoload.php";

$app = new Slim\App();
$container = $app->getContainer();
$container['renderer'] = new PugRenderer("./templates");

$app->get('/hello/{name}', function ($request, $response, $args) {
    return $this->renderer->render($response, "/hello.pug", $args);
});

$app->run();
```

Usage with any PSR-7 Project
----------------------------

[](#usage-with-any-psr-7-project)

```
//Construct the View
$pugView = new PugRenderer("./path/to/templates");

//Render a Template
$response = $pugView->render(new Response(), "/path/to/template.pug", $yourData);
```

Template Variables
------------------

[](#template-variables)

You can add variables to your renderer that will be available to all templates you render.

```
// via the constructor
$templateVariables = [
    "title" => "Title"
];
$pugView = new PugRenderer("./path/to/templates", $templateVariables);

// or setter
$pugView->setAttributes($templateVariables);

// or individually
$pugView->addAttribute($key, $value);
```

Data passed in via `->render()` takes precedence over attributes.

```
$templateVariables = [
    "title" => "Title"
];
$pugView = new PhpRenderer("./path/to/templates", $templateVariables);

//...

$pugView->render($response, $template, [
    "title" => "My Title"
]);
// In the view above, the $title will be "My Title" and not "Title"
```

Exceptions
----------

[](#exceptions)

`\RuntimeException` - if template does not exist

`\InvalidArgumentException` - if $data contains 'template'

References
----------

[](#references)

- To learn more about Pug go to
- Here is an online HTML to Pug converter

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

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

3246d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/126c34b4dff8d42336ea07ac5297bcc3ec0a0e306fd964a7497f02240da4b142?d=identicon)[md](/maintainers/md)

---

Top Contributors

[![MarcelloDuarte](https://avatars.githubusercontent.com/u/144535?v=4)](https://github.com/MarcelloDuarte "MarcelloDuarte (5 commits)")[![kylekatarnls](https://avatars.githubusercontent.com/u/5966783?v=4)](https://github.com/kylekatarnls "kylekatarnls (3 commits)")

### Embed Badge

![Health badge](/badges/md-pug-slim/health.svg)

```
[![Health](https://phpackages.com/badges/md-pug-slim/health.svg)](https://phpackages.com/packages/md-pug-slim)
```

###  Alternatives

[moonshine/moonshine

Laravel administration panel

1.3k217.1k59](/packages/moonshine-moonshine)[modx/revolution

MODX Revolution is a Content Management System

1.4k9.1k12](/packages/modx-revolution)[bkwld/laravel-pug

Pug view adapter for Laravel

15967.4k2](/packages/bkwld-laravel-pug)[rareloop/lumberjack-core

A powerful MVC framework for the modern WordPress developer. Write better, more expressive and easier to maintain code

42155.0k19](/packages/rareloop-lumberjack-core)[ci-pug/ci-pug

HAML-like template engine for CodeIgniter

211.7k](/packages/ci-pug-ci-pug)

PHPackages © 2026

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