Download the PHP package linkorb/custom-element without Composer
On this page you can find all versions of the php package linkorb/custom-element. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download linkorb/custom-element
More information about linkorb/custom-element
Files in linkorb/custom-element
Package custom-element
Short Description Custom element
License MIT
Homepage http://www.github.com/linkorb/custom-element
Informations about the package custom-element
Custom Element
This library allows you to define custom elements for usage in (Twig) templates.
Think of it as light-weight SSR (Server Side Rendererd) Web Components.
For example, you can create a new element such as <Avatar username="alice" imageUrl="https://example.web/alice.webp" bio="Hello world" />
Then you define a twig template elements/Avatar.html.twig
such as the following:
Your custom element can now be rendered using your custom element template. The template receives a variable for every specified attribute.
Custom elements will only be rendered if they start with an upper-case character (to distinguish standard from custom elements)
Usage
Symfony
Add the following to your services.yaml
to register the renderer and the twig extension:
The renderer
You can turn any raw HTML with custom elements into a rendered HTML output like this:
The Twig extension
You can render custom elements from any Twig template using the filter:
License
MIT. Please refer to the license file for details.
Brought to you by the LinkORB Engineering team
Check out our other projects at linkorb.com/engineering.
Btw, we're hiring!