Download the PHP package jascha030/wp-sequoia without Composer
On this page you can find all versions of the php package jascha030/wp-sequoia. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jascha030/wp-sequoia
More information about jascha030/wp-sequoia
Files in jascha030/wp-sequoia
Package wp-sequoia
Short Description Static HTML Component library using OOP Php in conjunction with the Twig templating language
License MIT
Informations about the package wp-sequoia
Sequoia
A Cheeky Component library for PHP, using the Twig templating language library and an OOP approach. Built with Wordpress in mind but not limited to Wordpress.
Prerequisites
- Php
^7.4 || ^8.0
- Composer
^2.0
Installation
Require as dependency by either; adding it directly to your composer.json
, or running:
Simple as that…
Usage
It’s all based around two interfaces:
TwigTemplaterInterface and the TwigComponentInterface and it’s main implementation TwigComponentAbstract.
Templater
Create a Templater which requires a Twig\Environment
instance.
(Preferably using a FilesystemLoader
).
Example
Let’s say you have a template in your templates folder called list-template.twig
Now you can extend the TwigComponentAbstract
.
Which can then be rendered like:
Using default values
You can also provide, defaults for a component using the HasDefaultContextTrait
like:
With Wordpress
When available the getContext
method used in rendering, will have an automatically generated filter, to mutate the defaults following the pattern:
twig_template_context_{$this->getTemplateSlug()}
Where $this->getTemplateSlug()
will by default return the template name defined in the getTemplate()
method, minus the .twig
appendix, in the above example this would be: twig_template_context_list-template
, which could then be used in the following context (in Wordpress):
Now you would hypothetically have added a third list item and the output of the ListComponent::render()
method would be:
Running UnitTests
To check wether your implementation is allright or if there is something wrong with the library while extending it. you can use:
Make sure to install with dev dependencies by using
composer install
instead ofcomposer install —no-dev
.More comming soon.
Inspiration
This is the start of a library based around the frustration with Wordpress, their messy template system, their messy user base, and the sadly, lately rarely updated timber/timber
library and
it’s overkill set of features.
It’s pretty specific and built mainly for myself and to make Front-end features a bit more fun to develop.
But maybe someone will ever find some use in this library as I hope to extend it and add loads of features, until it will reach a point of being just as overkill as timber
.
That being said, timber/timber
is a great library so support it if you use it, and even though Wordpress’ messy and old-timey nature, It’s a great tool for those who are learning or don’t aspire to be developers to build their website, which is obviously, why it has seen the great success, that it has.
And for those who are aspiring to be developers, beware of the fact that the coding styles of Wordpress are a great starting point, they are not how we develop code in the rest of the world, and based around old, long forgotten standards.
Shout out to those few internet heroes, who are finding and teaching how to do Wordpress development, in a more modern fashion.
If you are one who aspires to be one or is just plain bored by having to work with Wordpress, I suggest googling people like:
- Carl Alexander
- Josh Pollock
- The people from Roots (from bedrock, sage)