Download the PHP package hashandsalt/kirby-carver without Composer
On this page you can find all versions of the php package hashandsalt/kirby-carver. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download hashandsalt/kirby-carver
More information about hashandsalt/kirby-carver
Files in hashandsalt/kirby-carver
Package kirby-carver
Short Description Kirby 3 Carver plugin for using PHP and the power of Kirby to create custom html tags.
License MIT
Informations about the package kirby-carver
Kirby Carver
What it does
This plugin allows you to write custom HTML tags, powered by PHP.
Why?
Kirby is most awesome, but I do miss the simplicity of Textpattern's templating language, which looks like HTML. Having gone through available alternative templating engines like Twig and Blade, without much love, I decided to put this together.
For example, to get the a formatted date from a field, normally you would do something like this:
What if you could do this instead?
You can find some example tags in site/plugins/carver/library
Installation
- Download the files and place in
plugins/carver
- Create a folder called
carver
under thesite
folder. This is where you tags will be stored.
Usage
Let's create a simple tag as an example to show what this can do, based on the date tag mentioned above.
Start by creating the following file: 'site/carver/date/tag.php'.
Add this code to the file:
Let's explain how that works. Our tag looks like this:
It has three custom attributes, format
, field
and class
.
If you use that in your template right now, you will get this rendered, assuming you have a date field set in your blueprint with a value stored:
Pretty self explanatory, you can set the field to use, the class to give the output, and the date format to use. But thats not all - you can skip some of the attributes because fallbacks have been set.
Doing this in a template will use todays date instead, format it to 'd/m/Y', and without adding a class:
Will result in this:
More tag examples
Road Map
- Bring tag parser up to date
- Refactor tag parser to allow for options to be set via config
- Create a big library of built in tags that work with Kirby's built in functions.
- ~Composer support~
Dedication
When I am not using Kirby, I am using Textpattern. Sadly, Dean Allen, who created Textpattern died about a year ago. His philosophy of simplicity in a CMS aligns with that of Kirby, and this plugin is in his honour.