Skip to content

Commit a04aec6

Browse files
committed
Add CONTRIBUTING.md
1 parent 83257ee commit a04aec6

2 files changed

Lines changed: 46 additions & 2 deletions

File tree

CONTRIBUTING.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Contributing
2+
3+
You want to contribute to this module? Awesome! Here are a few links and guidelines to get you started.
4+
5+
* Check out the [documentation](DOCUMENTATION.md)
6+
* Report bugs or feature requests on [GitHub](https://github.com/wanze/TemplateEngineFactory/issues)
7+
* Use the [forum thread](https://processwire.com/talk/topic/6833-module-templateenginefactory/) to get support from the
8+
community
9+
10+
## Pull Requests
11+
12+
Pull requests are welcome! If you you add a feature, please discuss it first in a new issue or the forums.
13+
14+
* Open the pull request against the `master` branch for the `2.x` version, or against the `1.x` branch for the `1.x` version.
15+
* Make sure the tests are still green ✅.
16+
* Please try to add test cases for newly introduced features or bug fixes.
17+
* The module follows the [PSR-2](https://www.php-fig.org/psr/psr-2/) coding style and checks it with [styleci.io](https://styleci.io/).

DOCUMENTATION.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,20 @@ was previously defined on template engine level. If you have customized this set
2222
the `TemplateEngineFactory` module's config. Defaults to `templates/views`.
2323
* _Chunks_ are now called _Controllers_. While the semantics remain the same, the public API has changed. Please
2424
read the [Controllers](#controllers) chapter on how to update your code.
25-
* The method `TemplateEngineFactory::instance()` (plus some aliases) do no longer exist. Use
25+
* The method `TemplateEngineFactory::instance()`, plus some aliases do no longer exist. Use
2626
`TemplateEngineFactory::render()` to render a given template of the engine.
2727
* On template engine level, the confusing `global_template` setting does no longer exist. Use the introduced hook
2828
`___resolveTemplate` to resolve a custom template when a page gets rendered. The default strategy still looks for a template
2929
with the same name as the ProcessWire template.
3030

31+
> Make sure to clear the compiled files cache after replacing the module files! Press _Clear Compiled Files_ at the
32+
bottom when viewing the site's modules in the ProcessWire admin. Or simply delete anything in `./site/assets/cache/`.
33+
3134
## Controllers
3235

3336
A _controller_ wraps a ProcessWire template executing some logic and a template file of the active engine, rendering the
3437
output. This is how the _Automatic page rendering_ feature works, by using the template file of a page as controller. By
35-
defining custom controllers, you get the the same functionality:
38+
defining custom controllers, you get the same functionality without depending on a page:
3639

3740
```php
3841
$factory = $modules->get('TemplateEngineFactory');
@@ -141,7 +144,31 @@ wire()->addHookAfter('TemplateEngineFactory::shouldRenderPage', function (HookEv
141144

142145
## Best Practices
143146

147+
Write me please 😬
148+
144149
## Implementing a Template Engine
145150

151+
Adding your favorite template engine to the factory is really easy.
152+
153+
* Each template engine is added via ProcessWire module. This module provides the template engine's configuration and
154+
registers the engine to the factory.
155+
* The engine itself is implemented using the `TemplateEngineFactory\TemplateEngineInterface` contract.
156+
* The factory provides an abstract base implementation `TemplateEngineFactory\TemplateEngineBase` which your engine
157+
should extend.
158+
159+
For an example, take a look at the [TemplateEngineTwig](https://github.com/wanze/TemplateEngineTwig) implementation.
160+
146161
## Running Tests
147162

163+
The module includes [PHPUnit](https://phpunit.de/) based tests cases, located in the `./tests` directory.
164+
165+
* Make sure that the dev dependencies are installed by running `composer install` in the ProcessWire root directory.
166+
* The tests will create pages and templates. Everything should get cleaned up properly, but you should not run them
167+
on a production environment 😉.
168+
169+
To run the tests:
170+
171+
```
172+
vendor/bin/phpunit --bootstrap site/modules/TemplateEngineFactory/tests/bootstrap.php site/modules/TemplateEngineFactory/tests/src
173+
```
174+

0 commit comments

Comments
 (0)