mouf / html.renderer
This package contains the rendering mechanism of the Mouf framework. It is a mechanism allowing packages/templates/developers to overload a default template for various HTML objects.
Installs: 356 038
Dependents: 6
Suggesters: 0
Security: 0
Stars: 0
Watchers: 14
Forks: 4
Open Issues: 2
Requires
- php: ^8.0
- container-interop/service-provider: ^0.4
- mindplay/composer-locator: ^2.1.3
- mouf/html.htmlelement: ~2.0
- mouf/html.renderer.twig-extensions: ^3
- mouf/utils.cache.apc-cache: ~2.0
- psr/container: ^1
- psr/http-message: ^1
- psr/http-server-handler: ^1
- psr/http-server-middleware: ^1
- psr/simple-cache: ^1
- thecodingmachine/funky: ^1
- thecodingmachine/middleware-list-universal-module: ^1.1.1
- twig/twig: ^1 || ^2
Requires (Dev)
README
What is this package?
This package contains a rendering mechanism to render objects in HTML.
For application developers
You are an application developer? Learn how to use the rendering system with PHP files or Twig templates to render your objects or overload renderers provided by packages.
See the video!
<iframe width="480" height="360" src="//www.youtube.com/embed/f2MyYSUic1U" frameborder="0" allowfullscreen></iframe>For package developers
You are a package developer? Learn how to use the rendering system to allow other users to overload your renderers easily.
Installation
$ composer require mouf/html.renderer ^2
The easiest way to use this package is through a dependency injection container compatible with container-interop/service-providers.
Once installed, you need to register the Mouf\Html\Renderer\RendererServiceProvider
into your container.
If your container supports thecodingmachine/discovery integration, you have nothing to do. Otherwise, refer to your framework or container's documentation to learn how to register service providers.
Provided services
This service provider provides the following services:
Extended services
This service provider extends those services:
Mouf package
This package was originally part of Mouf (http://mouf-php.com), an effort to ensure good developing practices by providing a graphical dependency injection framework.
V2 makes the package framework-agnostic, so it can be used in any framework.
Basically, you will find in this package some Renderers. These are classes in charge of rendering other objects. They usually rely on template files, that contain the HTML to be rendered. Renderers can be chained, and the first renderer that knows how to render an object will be in charge of the rendering.
Troubleshooting
Your template or a custom template is not applied.
- Purge the cache with the red button in mouf.
- You use Ajax and you return html with echo (for example BCE).
- By default an echo don't apply the template to make it
- add the defaultRenderer (a class of Mouf\Html\Renderer\AutoChainRenderer) in your class
- add your templateRenderer (a class of Mouf\Html\Renderer\FileBasedRenderer) in Bootstrap this is bootstrapRenderer
- add the code before your call to the function toHTML: $this->defaultRenderer->setTemplateRenderer($this->templateRenderer);
- By default an echo don't apply the template to make it