{"id":13721574,"url":"https://github.com/pug-php/pug-slim","last_synced_at":"2025-05-07T13:33:27.256Z","repository":{"id":27457051,"uuid":"95650139","full_name":"pug-php/pug-slim","owner":"pug-php","description":"Pug template engine adapter for Slim","archived":false,"fork":true,"pushed_at":"2022-02-13T11:24:09.000Z","size":34,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-05-11T00:34:26.738Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"MarcelloDuarte/pug-slim","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pug-php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-06-28T09:03:08.000Z","updated_at":"2023-04-24T12:19:54.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/pug-php/pug-slim","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pug-php%2Fpug-slim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pug-php%2Fpug-slim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pug-php%2Fpug-slim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pug-php%2Fpug-slim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pug-php","download_url":"https://codeload.github.com/pug-php/pug-slim/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224605046,"owners_count":17339253,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T01:01:18.793Z","updated_at":"2024-11-14T10:31:47.384Z","avatar_url":"https://github.com/pug-php.png","language":"PHP","readme":"# Pug for Slim\n\n[![Latest Stable Version](https://poser.pugx.org/pug/slim/v/stable.png)](https://packagist.org/packages/pug/slim)\n[![Build Status](https://travis-ci.org/pug-php/pug-slim.svg?branch=master)](https://travis-ci.org/pug-php/pug-slim)\n[![Code Climate](https://codeclimate.com/github/pug-php/pug-slim/badges/gpa.svg)](https://codeclimate.com/github/pug-php/pug-slim)\n[![Test Coverage](https://codeclimate.com/github/pug-php/pug-slim/badges/coverage.svg)](https://codeclimate.com/github/pug-php/pug-slim/coverage)\n[![Issue Count](https://codeclimate.com/github/pug-php/pug-slim/badges/issue_count.svg)](https://codeclimate.com/github/pug-php/pug-slim)\n[![StyleCI](https://styleci.io/repos/95650139/shield?branch=master)](https://styleci.io/repos/95650139)\n\nFor details about the template engine see [phug-lang.com](https://www.phug-lang.com)\n\n## Installation\n\nInstall with [Composer](http://getcomposer.org):\n\n```bash\ncomposer require pug/slim\n```\n\n## Usage with Slim 3\n\n```php\nuse Slim\\App;\nuse Slim\\Pug\\PugRenderer;\n\ninclude 'vendor/autoload.php';\n\n$slimOptions = []; // here you can pass Slim settings\n$app = PugRenderer::create(new App($slimOptions), './templates');\n\n$app-\u003eget('/hello/{name}', function ($request, $response, $args) {\n    return $this-\u003erenderer-\u003erender($response, 'hello.pug', $args);\n});\n\n$app-\u003erun();\n```\n\nPS: If you don't pass an application to the `create` method, we\nwill automatically initialize one, so you can just do:\n\n```php\nuse Slim\\Pug\\PugRenderer;\n\ninclude 'vendor/autoload.php';\n\n$app = PugRenderer::create(null, './templates');\n```\n\n\n## Usage with any PSR-7 Project\n\n```php\n//Construct the View\n$pugView = new PugRenderer('./path/to/templates', [\n  'option' =\u003e 'foobar',\n]);\n\n//Render a Template\n$response = $pugView-\u003erender(new Response(), '/path/to/template.pug', $yourData);\n```\n\n## Template Variables\n\nYou can add variables to your renderer that will be available to all templates you render.\n\n```php\n// via the constructor\n$templateVariables = [\n  'title' =\u003e 'Title',\n];\n$pugView = new PugRenderer('./path/to/templates', [], $templateVariables);\n\n// or setter\n$pugView-\u003esetAttributes($templateVariables);\n\n// or individually\n$pugView-\u003eaddAttribute($key, $value);\n```\n\nData passed in via `-\u003erender()` takes precedence over attributes.\n```php\n$templateVariables = [\n  'title' =\u003e 'Title',\n];\n$pugView = new PhpRenderer('./path/to/templates', $templateVariables);\n\n//...\n\n$pugView-\u003erender($response, $template, [\n    'title' =\u003e 'My Title',\n]);\n// In the view above, the $title will be \"My Title\" and not \"Title\"\n```\n\nBy default, [pug-php](https://github.com/pug-php/pug) is used.\nBut you can specify an other engine:\n```php\n$app = PugRenderer::create(null, null, [\n  'renderer' =\u003e \\Phug\\Renderer::class,\n]);\n```\nPS: Phug is automatically installed with default install since Pug-php 3\nuse it internally. But you can also install different renderer engine,\nfor example tale-pug:\n```bash\ncomposer require talesoft/tale-pug\n```\n```php\n$app = PugRenderer::create(null, null, [\n  'renderer' =\u003e \\Tale\\Pug\\Renderer::class,\n]);\n```\nNote that in this case, you have no guarantee that all options\nwill work. \n\n## References\n\n * Pug-php 3 / Phug official documentation [www.phug-lang.com](https://www.phug-lang.com)\n * Pug-php 3 / Phug live editor [pug-demo.herokuapp.com](https://pug-demo.herokuapp.com)\n * To learn more about Pug go to [pugjs.org](https://pugjs.org)\n * Here is an online HTML to Pug converter [html2pug.herokuapp.com](https://html2pug.herokuapp.com/)\n \n## Credits\n\nThis project is forked from https://github.com/MarcelloDuarte/pug-slim\nAnd we added to it phug, pug-php 3, tale-jade and tale-pug support.\n","funding_links":[],"categories":["Tools"],"sub_categories":["Frameworks"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpug-php%2Fpug-slim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpug-php%2Fpug-slim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpug-php%2Fpug-slim/lists"}