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(9y 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 4w 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 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

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

3294d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/70713?v=4)[md](/maintainers/md)[@md](https://github.com/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

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.5k](/packages/aws-aws-sdk-php)[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[guzzlehttp/psr7

PSR-7 message implementation that also provides common utility methods

8.0k1.1B3.9k](/packages/guzzlehttp-psr7)[moonshine/moonshine

Laravel administration panel

1.3k253.1k78](/packages/moonshine-moonshine)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69735.1M154](/packages/algolia-algoliasearch-client-php)

PHPackages © 2026

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