ekandreas / bladerunner

WordPress plugin for Laravel Blade templating DEPRECATED
http://bladerunner.elseif.se
12 stars 1 forks source link

Creating Custom Directives #74

Closed Pushplaybang closed 6 years ago

Pushplaybang commented 6 years ago

I've been looking at implementing blade into my project and tried two or three libraries before I eventually found yours. It generally looks great, and to be the best option. Any tips on how to create custom directives?

vpillinger commented 6 years ago

I have been playing around with this plugin and found out how to hook into this.

In the Laravel Framework, Blade has a facade that allows creating directives easy. Ex) Blade::directive(function(){}). Well, this facade is just a wrapper for the Blade instance, which has the actual method for registering directives.

Skipping past all the inner-workings of Blade, in order to create a blade directive two things need to happen. 1) You need to get an instance of the compiler. 2) You need to call directive() or if() on it to register your compiler.

Currently, the setup.php script in bladerunner/globals/setup.php makes it possible to register a directive like in the screenshot below, but I am still trying to figure out if/how to make this globally available without editing the package. If you see #78 I made a note that its possible to move bladrunner into your theme, which will allow you to edit it, but doing so will certainly limit your upgrade options. image

Pushplaybang commented 6 years ago

yeah, have moved to sage 9, eventually found, all the things I wanted to do, blade / better handling of data models / clean well structured modern PHP / controllers / web pack all setup for you and ready to go.

ekandreas commented 6 years ago

Yes, Bladerunner is a fraction of Sage. In fact the code is copied from the project without all the bloat. So to be clear, this is a plugin and Sage is a theme. But that you know :-)