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

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

pug/slim
========

Pug template engine adapter for Slim

1.4.0(2mo ago)61.0k1MITPHPCI passing

Since Jun 25Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/pug-php/pug-slim)[ Packagist](https://packagist.org/packages/pug/slim)[ GitHub Sponsors](https://github.com/kylekatarnls)[ Fund](https://opencollective.com/pug-php)[ RSS](/packages/pug-slim/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (4)Dependencies (11)Versions (6)Used By (0)

Pug for Slim
============

[](#pug-for-slim)

[![Latest Stable Version](https://camo.githubusercontent.com/d266c3fd46ce950ac7f181a87fe03e1643e1ca0853659f1786e60272654bfef5/68747470733a2f2f706f7365722e707567782e6f72672f7075672f736c696d2f762f737461626c652e706e67)](https://packagist.org/packages/pug/slim)[![Build Status](https://camo.githubusercontent.com/dda35f8e7ee39b18032edc9649e61c8973bfb1d79c35991afdb85df43e6c4801/68747470733a2f2f7472617669732d63692e6f72672f7075672d7068702f7075672d736c696d2e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/pug-php/pug-slim)[![Code Climate](https://camo.githubusercontent.com/3519caca0ebffb8599c8590a942c452a46067e13a51bb30e594401f58d2ff804/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f7075672d7068702f7075672d736c696d2f6261646765732f6770612e737667)](https://codeclimate.com/github/pug-php/pug-slim)[![Test Coverage](https://camo.githubusercontent.com/f3933ff253f3b5fcf410b573c04358f2676e861b410c85b2c406506e604dffcc/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f7075672d7068702f7075672d736c696d2f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/pug-php/pug-slim/coverage)[![Issue Count](https://camo.githubusercontent.com/4f7ffe158a7cd6e54a105342af01d257d88b9a1071c579d3b16508ea04de5b79/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f7075672d7068702f7075672d736c696d2f6261646765732f69737375655f636f756e742e737667)](https://codeclimate.com/github/pug-php/pug-slim)[![StyleCI](https://camo.githubusercontent.com/9d17376f72c37d0fc291ab6666ae371251fffdaa7708fcc2c894468fe09b7745/68747470733a2f2f7374796c6563692e696f2f7265706f732f39353635303133392f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/95650139)

For details about the template engine see [phug-lang.com](https://www.phug-lang.com)

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

[](#installation)

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

```
composer require pug/slim
```

Usage with Slim 4
-----------------

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

**routes.php**

```
use Slim\Pug\PugRenderer;

// ...

$app->get('/', function (Request $request, Response $response) {
    $renderer = new PugRenderer([
        // The base folder containing the pug template files
        // In this example we assume a home.pug file exist in it
        'basedir' => __DIR__ . '/../templates',
    ]);

    $viewData = [
        'name' => 'John',
    ];

    return $renderer->render($response, 'home.pug', $viewData);
});
```

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

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

```
use Slim\App;
use Slim\Pug\PugRenderer;

include 'vendor/autoload.php';

$slimOptions = []; // here you can pass Slim settings
$app = PugRenderer::create(new App($slimOptions), './templates');

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

$app->run();
```

PS: If you don't pass an application to the `create` method, we will automatically initialize one, so you can just do:

```
use Slim\Pug\PugRenderer;

include 'vendor/autoload.php';

$app = PugRenderer::create(null, './templates');
```

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

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

```
//Construct the View
$pugView = new PugRenderer('./path/to/templates', [
  // Here you can set options
]);

//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"
```

By default, [pug-php](https://github.com/pug-php/pug) is used. But you can specify an other engine:

```
$app = PugRenderer::create(null, null, [
  'renderer' => \Phug\Renderer::class,
]);
```

PS: Phug is automatically installed with default install since Pug-php 3 use it internally. But you can also install different renderer engine, for example tale-pug:

```
composer require talesoft/tale-pug
```

```
$app = PugRenderer::create(null, null, [
  'renderer' => \Tale\Pug\Renderer::class,
]);
```

Note that in this case, you have no guarantee that all options will work.

References
----------

[](#references)

- Pug-php 3 / Phug official documentation [www.phug-lang.com](https://www.phug-lang.com)
- Pug-php 3 / Phug live editor [pug-demo.herokuapp.com](https://pug-demo.herokuapp.com)
- To learn more about Pug go to [pugjs.org](https://pugjs.org)
- Here is an online HTML to Pug converter [html2pug.herokuapp.com](https://html2pug.herokuapp.com/)

Credits
-------

[](#credits)

This project is forked from And we added to it phug, pug-php 3, tale-jade and tale-pug support.

###  Health Score

50

—

FairBetter than 96% of packages

Maintenance88

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 86.4% 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 ~797 days

Total

5

Last Release

62d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

phpslimhtmljadepugphug

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[phug/phug

Pug (ex-Jade) facade engine for PHP, HTML template engine structured by indentation

67292.2k13](/packages/phug-phug)[talesoft/tale-pug

A clean, lightweight and easy-to-use templating engine for PHP based on Pug, formerly Jade

319.4k3](/packages/talesoft-tale-pug)[talesoft/tale-jade

A clean, lightweight and easy-to-use templating engine for PHP based on Jade/Pug

8919.3k5](/packages/talesoft-tale-jade)[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)
