https://github.com/antidot-framework/phug-template-renderer
Antidot Framework Phug template renderer library
https://github.com/antidot-framework/phug-template-renderer
Last synced: over 1 year ago
JSON representation
Antidot Framework Phug template renderer library
- Host: GitHub
- URL: https://github.com/antidot-framework/phug-template-renderer
- Owner: antidot-framework
- License: bsd-2-clause
- Created: 2019-04-13T21:34:11.000Z (about 7 years ago)
- Default Branch: 1.x.x
- Last Pushed: 2021-11-01T17:02:18.000Z (over 4 years ago)
- Last Synced: 2025-01-06T07:23:23.757Z (over 1 year ago)
- Language: PHP
- Homepage: https://template.antidotfw.io
- Size: 24.4 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# Antidot Framework Phug Template Renderer
[](https://scrutinizer-ci.com/g/antidot-framework/phug-template-renderer/?branch=master)
[](https://scrutinizer-ci.com/g/antidot-framework/phug-template-renderer/?branch=master)
[](https://scrutinizer-ci.com/g/antidot-framework/phug-template-renderer/build-status/master)
[](https://scrutinizer-ci.com/code-intelligence)
## Install
Using composer
```bash
composer require antidot-fw/phug-template-renderer
```
### Antidot framework
It will work out of the box, the only thing you need is to inject the TemplateRenderer interface in your request handler constructor
### As standalone component
See factory classes at `src/Container`.
## Config
```php
[
'pretty' => true,
'expressionLanguage' => 'js',
'pugjs' => false,
'localsJsonFile' => false,
'cache' => 'var/cache/pug',
'template_path' => 'templates/',
'globals' => [],
'filters' => [],
'keywords' => [],
'helpers' => [],
'default_params' => [],
],
];
```
## Usage
See full [PHP Pug documentation](https://www.phug-lang.com/) for more detail.
### In a request handler
```php
template = $template;
}
public function handle(ServerRequestInterface $request) : ResponseInterface
{
return new HtmlResponse(
$this->template->render('index', [
'name' => 'Koldo ;-D',
])
);
}
}
```
```pug
// templates/index.pug
html
head
title Antidot Todo List app
link(rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css")
link(href="//fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet")
body
main
section(class="container")
h1 Hello #{name}
script(type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js")
block scripts
```