From c94a28337aeba4cf6464fb4f2fae4ade26bb9377 Mon Sep 17 00:00:00 2001 From: Andreas Ek Date: Fri, 18 Aug 2017 16:36:29 +0000 Subject: [PATCH 01/23] Apply fixes from StyleCI --- globals/filters.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/globals/filters.php b/globals/filters.php index 0b4660f..ee6de0a 100644 --- a/globals/filters.php +++ b/globals/filters.php @@ -18,7 +18,9 @@ ])->unique()->toArray(); foreach ($controllerPaths as $path) { - if(!is_string($path)) continue; + if (!is_string($path)) { + continue; + } $controllerPath = "{$path}/{$normalizedTemplate}.php"; if (file_exists($controllerPath)) { add_filter('bladerunner/controllers/heap', function ($heap) use ($controllerPath) { From a6c9708272c4a8e799440d5466c45e8a56ed52c7 Mon Sep 17 00:00:00 2001 From: Vincent Klaiber Date: Wed, 30 Aug 2017 18:31:49 +0200 Subject: [PATCH 02/23] Update composer.json Updated the composer.json file based on comments from GitHub and Twitter. --- composer.json | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/composer.json b/composer.json index 62204a6..b4d5864 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,6 @@ { "name": "ekandreas/bladerunner", "type": "wordpress-plugin", - "version": "1.7.1-dev", "description": "WordPress Blade L5 template engine", "keywords": ["laravel", "blade", "wordpress"], "license": "MIT", @@ -12,26 +11,30 @@ } ], "require": { - "php": ">=5.6", - "illuminate/config": "5.*", - "illuminate/view": "5.*", - "symfony/yaml": "3.*", - "brain/hierarchy":"2.*" + "php": "^5.6 || ^7.0", + "illuminate/config": "^5.0", + "illuminate/view": "^5.0", + "symfony/yaml": "^3.0", + "brain/hierarchy": "^2.0" + }, + "require-dev": { + "frozzare/wp-test-suite": "*" }, "autoload": { "psr-4": { - "Bladerunner\\Tests\\": "tests/", "Bladerunner\\": "src/" } }, - "prefer-stable": true, - "minimum-stability": "dev", - "require-dev": { - "frozzare/wp-test-suite": "*" + "autoload-dev": { + "psr-4": { + "Bladerunner\\Tests\\": "tests/" + } }, "extra": { "branch-alias": { - "dev-develop": "1.7.1-dev" + "dev-develop": "1.7-dev" } - } -} + }, + "minimum-stability": "dev", + "prefer-stable": true +} \ No newline at end of file From 4d07da6a192b676077a4d5bc64171ebd4b04b101 Mon Sep 17 00:00:00 2001 From: Andreas Ek Date: Thu, 31 Aug 2017 14:26:37 +0200 Subject: [PATCH 03/23] Switching dev to master branch --- globals/setup.php | 1 - readme.md | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/globals/setup.php b/globals/setup.php index ed5c8cb..b7e4aa3 100644 --- a/globals/setup.php +++ b/globals/setup.php @@ -55,7 +55,6 @@ $extensions = apply_filters('bladerunner/extend', []); - var_dump($extensions); if ($extensions && is_array($extensions)) { foreach ($extensions as $extension) { if (is_callable($extension)) { diff --git a/readme.md b/readme.md index 6c6949d..a05cf52 100644 --- a/readme.md +++ b/readme.md @@ -12,7 +12,7 @@ WordPress plugin for Laravel Blade templating. To install it to your Composer based WordPress installation: ``` -composer require ekandreas/bladerunner:* +composer require ekandreas/bladerunner ``` Activate the plugin inside WordPress and templates with *.blade.php are inspected and active. Your theme still needs an index.php due to WordPress basic functionality. When removed the theme is known as broken. From eb3cc611797ef3c81f65407ca1ef89dacb44a7c4 Mon Sep 17 00:00:00 2001 From: Andreas Ek Date: Thu, 31 Aug 2017 14:29:00 +0200 Subject: [PATCH 04/23] Prepp dev 1.7.2 --- bladerunner.php | 2 +- composer.json | 2 +- readme.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bladerunner.php b/bladerunner.php index 0a5d3f7..798722e 100644 --- a/bladerunner.php +++ b/bladerunner.php @@ -3,7 +3,7 @@ Plugin Name: Bladerunner Plugin URI: http://bladerunner.elseif.se Description: Laravel Blade template engine for WordPress -Version: 1.7.1-dev +Version: 1.7.2-dev Author: Andreas Ek Author URI: https://www.elseif.se/ License: MIT License diff --git a/composer.json b/composer.json index b4d5864..a835e29 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ }, "extra": { "branch-alias": { - "dev-develop": "1.7-dev" + "dev-master": "1.7.2-dev" } }, "minimum-stability": "dev", diff --git a/readme.txt b/readme.txt index acc49e3..a27a5d8 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: ekandreas Tags: Blade,templates,development,laravel Requires at least: 4.4 Tested up to: 4.8.1 -Stable tag: 1.7.1-dev +Stable tag: 1.7.2-dev License: MIT WordPress plugin for Blade L5 templating From fe2f6c82d97699deeaf3bc6db02aff67254db7c2 Mon Sep 17 00:00:00 2001 From: Andreas Ek Date: Thu, 31 Aug 2017 20:08:25 +0200 Subject: [PATCH 05/23] Examine extensions and if-statements with L5 --- globals/setup.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/globals/setup.php b/globals/setup.php index b7e4aa3..5da6623 100644 --- a/globals/setup.php +++ b/globals/setup.php @@ -48,12 +48,6 @@ return ''; }); - if (defined('WP_DEBUG') && WP_DEBUG) { - array_map('unlink', - glob(\Bladerunner\Config::repo('view.compiled') . '/*')); - } - - $extensions = apply_filters('bladerunner/extend', []); if ($extensions && is_array($extensions)) { foreach ($extensions as $extension) { @@ -62,6 +56,12 @@ } } } + + if (defined('WP_DEBUG') && WP_DEBUG) { + array_map('unlink', + glob(\Bladerunner\Config::repo('view.compiled') . '/*')); + } + }); /** From 3a3290b36a18d4ba02fc595fa3b377e20678876f Mon Sep 17 00:00:00 2001 From: Andreas Ek Date: Thu, 31 Aug 2017 18:08:34 +0000 Subject: [PATCH 06/23] Apply fixes from StyleCI --- globals/setup.php | 1 - 1 file changed, 1 deletion(-) diff --git a/globals/setup.php b/globals/setup.php index 5da6623..2e687eb 100644 --- a/globals/setup.php +++ b/globals/setup.php @@ -61,7 +61,6 @@ array_map('unlink', glob(\Bladerunner\Config::repo('view.compiled') . '/*')); } - }); /** From dc0e4ded21f9bec8549b7d488cd9ca6d2ef882cb Mon Sep 17 00:00:00 2001 From: Andreas Ek Date: Tue, 17 Oct 2017 15:05:25 +0200 Subject: [PATCH 07/23] Paths in controller --- composer.json | 2 +- globals/filters.php | 29 +++++++++++++++++++++++------ 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/composer.json b/composer.json index a835e29..085314e 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.7.2-dev" + "dev-master": "1.7.3" } }, "minimum-stability": "dev", diff --git a/globals/filters.php b/globals/filters.php index de3341e..7e7d5d5 100644 --- a/globals/filters.php +++ b/globals/filters.php @@ -12,10 +12,13 @@ ]; $normalizedTemplate = preg_replace(array_keys($transforms), array_values($transforms), $template); - $controllerPaths = collect([ - apply_filters('bladerunner/controller/paths', []), - get_stylesheet_directory() . '/controllers', - ])->unique()->toArray(); + $paths = apply_filters('bladerunner/controller/paths', []); + if (!is_array($paths)) { + $paths = [$paths]; + } + $paths[] = get_stylesheet_directory() . '/controllers'; + + $controllerPaths = collect($paths)->unique()->toArray(); foreach ($controllerPaths as $path) { if (!is_string($path)) { @@ -39,8 +42,22 @@ return $result; }); }, [ - 'index', '404', 'archive', 'author', 'category', 'tag', 'taxonomy', 'date', 'home', - 'frontpage', 'page', 'paged', 'search', 'single', 'singular', 'attachment' + 'index', + '404', + 'archive', + 'author', + 'category', + 'tag', + 'taxonomy', + 'date', + 'home', + 'frontpage', + 'page', + 'paged', + 'search', + 'single', + 'singular', + 'attachment' ]); add_filter('template_include', function ($template) { From 1376ba3166c7b8d43c983efcf4d78e8c923925d4 Mon Sep 17 00:00:00 2001 From: Andreas Ek Date: Tue, 17 Oct 2017 15:15:03 +0200 Subject: [PATCH 08/23] Version update --- bladerunner.php | 2 +- readme.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bladerunner.php b/bladerunner.php index 798722e..bc73e9d 100644 --- a/bladerunner.php +++ b/bladerunner.php @@ -3,7 +3,7 @@ Plugin Name: Bladerunner Plugin URI: http://bladerunner.elseif.se Description: Laravel Blade template engine for WordPress -Version: 1.7.2-dev +Version: 1.7.3 Author: Andreas Ek Author URI: https://www.elseif.se/ License: MIT License diff --git a/readme.txt b/readme.txt index a27a5d8..9765b8f 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: ekandreas Tags: Blade,templates,development,laravel Requires at least: 4.4 Tested up to: 4.8.1 -Stable tag: 1.7.2-dev +Stable tag: 1.7.3 License: MIT WordPress plugin for Blade L5 templating From 398d6d3650cab05a68e1fa4a83b710e0cba4ed06 Mon Sep 17 00:00:00 2001 From: Andreas Ek Date: Tue, 17 Oct 2017 15:18:17 +0200 Subject: [PATCH 09/23] Add version to composer.json to trigger packagist --- composer.json | 1 + 1 file changed, 1 insertion(+) diff --git a/composer.json b/composer.json index 085314e..76fa5e5 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,7 @@ { "name": "ekandreas/bladerunner", "type": "wordpress-plugin", + "version": "1.7.3", "description": "WordPress Blade L5 template engine", "keywords": ["laravel", "blade", "wordpress"], "license": "MIT", From 1cd36bfc9657de02d9edd0830137d6d21c6f7a7d Mon Sep 17 00:00:00 2001 From: Andreas Ek Date: Tue, 17 Oct 2017 15:25:38 +0200 Subject: [PATCH 10/23] No version to composer file, using branch-alias --- composer.json | 1 - 1 file changed, 1 deletion(-) diff --git a/composer.json b/composer.json index 76fa5e5..085314e 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,6 @@ { "name": "ekandreas/bladerunner", "type": "wordpress-plugin", - "version": "1.7.3", "description": "WordPress Blade L5 template engine", "keywords": ["laravel", "blade", "wordpress"], "license": "MIT", From e1584e0ddd6c3d8777fbb1971cb6260296c76bc4 Mon Sep 17 00:00:00 2001 From: Andreas Ek Date: Tue, 17 Oct 2017 15:30:21 +0200 Subject: [PATCH 11/23] Dev on branch alias --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 085314e..72bc4c8 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.7.3" + "dev-master": "1.7.3-dev" } }, "minimum-stability": "dev", From 7acce1c05c5b8c07646ade84a008eb0a8a283496 Mon Sep 17 00:00:00 2001 From: Andreas Ek Date: Tue, 17 Oct 2017 16:11:38 +0200 Subject: [PATCH 12/23] Blade path adjusted --- composer.json | 2 +- globals/setup.php | 23 +++++++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/composer.json b/composer.json index 72bc4c8..14a5ca2 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.7.3-dev" + "dev-master": "1.7.4-dev" } }, "minimum-stability": "dev", diff --git a/globals/setup.php b/globals/setup.php index 2e687eb..a73ee4b 100644 --- a/globals/setup.php +++ b/globals/setup.php @@ -17,15 +17,22 @@ 'uri.template' => get_template_directory_uri(), ]; - $viewPaths = collect(preg_replace('%[\/]?(templates)?[\/.]*?$%', '', [ - apply_filters('bladerunner/template/bladepath', $paths['dir.stylesheet']), - $paths['dir.stylesheet'] . DIRECTORY_SEPARATOR . 'views', - STYLESHEETPATH, - TEMPLATEPATH, - ])) + $bladePaths = apply_filters('bladerunner/template/bladepath', $paths['dir.stylesheet']); + if (!is_array($bladePaths)) { + $bladePaths = [$bladePaths]; + } + + $bladePaths[] = $paths['dir.stylesheet'] . DIRECTORY_SEPARATOR . 'views'; + $bladePaths[] = STYLESHEETPATH; + $bladePaths[] = TEMPLATEPATH; + + $viewPaths = array_values(collect($bladePaths, preg_replace('%[\/]?(templates)?[\/.]*?$%', '', $bladePaths)) ->flatMap(function ($path) { + if (strstr($path, '/views')) { + return [$path, $path]; + } return ["{$path}/templates", $path]; - })->unique()->toArray(); + })->unique()->toArray()); \Bladerunner\Config::repo([ 'view.compiled' => "{$paths['dir.upload']}/.cache", @@ -59,7 +66,7 @@ if (defined('WP_DEBUG') && WP_DEBUG) { array_map('unlink', - glob(\Bladerunner\Config::repo('view.compiled') . '/*')); + glob(\Bladerunner\Config::repo('view.compiled') . '/*')); } }); From 1ca331157e204848d20d6da07945061de1815eda Mon Sep 17 00:00:00 2001 From: Fredrik Forsmo Date: Tue, 17 Oct 2017 20:15:29 +0200 Subject: [PATCH 13/23] Update readme with some code tags Instead of using quotes or nothing at al it looks better to wrap them in code tags :) --- readme.md | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/readme.md b/readme.md index a05cf52..8885eab 100644 --- a/readme.md +++ b/readme.md @@ -23,14 +23,14 @@ Releases to this plugin is listed last in this readme. ## Hello World 1. Install the library with composer -2. Make sure the cache-folder is writeable in uploads, eg ../wp-content/uploads/.cache +2. Make sure the cache-folder is writeable in uploads, eg `../wp-content/uploads/.cache` 3. Activate the plugin 4. Create a view, eg: ```twig Hello World Page rendered at {{ date('Y-m-d H:i:s') }} ``` -5. In your index.php, add a global call for the view created, eg: +5. In your `index.php`, add a global call for the view created, eg: ```php $module]); @@ -88,7 +88,7 @@ Extend the Controller Class, it is recommended that the class name matches the f Create methods within the Controller Class: * Use public function to expose the returned values to the Blade views/s. * Use public static function to use the function within your Blade view/s. -* Use protected function for internal controller methods as only public methods are exposed to the view. You can run them within __construct. +* Use protected function for internal controller methods as only public methods are exposed to the view. You can run them within `__construct` ### Controller example: From 87b09c82b0a83eebbde849bd5e8e1652bb2fbb73 Mon Sep 17 00:00:00 2001 From: Andreas Ek Date: Tue, 17 Oct 2017 22:15:57 +0200 Subject: [PATCH 14/23] Template Path optimizations --- bladerunner.php | 2 +- globals/setup.php | 19 +------------------ readme.txt | 2 +- src/Config.php | 37 +++++++++++++++++++++++++++++++++++++ src/Container.php | 8 ++++---- src/Controller.php | 4 ++++ src/ControllerDebug.php | 7 ++++--- 7 files changed, 52 insertions(+), 27 deletions(-) diff --git a/bladerunner.php b/bladerunner.php index bc73e9d..cbf4589 100644 --- a/bladerunner.php +++ b/bladerunner.php @@ -3,7 +3,7 @@ Plugin Name: Bladerunner Plugin URI: http://bladerunner.elseif.se Description: Laravel Blade template engine for WordPress -Version: 1.7.3 +Version: 1.7.4 Author: Andreas Ek Author URI: https://www.elseif.se/ License: MIT License diff --git a/globals/setup.php b/globals/setup.php index a73ee4b..978c679 100644 --- a/globals/setup.php +++ b/globals/setup.php @@ -17,26 +17,9 @@ 'uri.template' => get_template_directory_uri(), ]; - $bladePaths = apply_filters('bladerunner/template/bladepath', $paths['dir.stylesheet']); - if (!is_array($bladePaths)) { - $bladePaths = [$bladePaths]; - } - - $bladePaths[] = $paths['dir.stylesheet'] . DIRECTORY_SEPARATOR . 'views'; - $bladePaths[] = STYLESHEETPATH; - $bladePaths[] = TEMPLATEPATH; - - $viewPaths = array_values(collect($bladePaths, preg_replace('%[\/]?(templates)?[\/.]*?$%', '', $bladePaths)) - ->flatMap(function ($path) { - if (strstr($path, '/views')) { - return [$path, $path]; - } - return ["{$path}/templates", $path]; - })->unique()->toArray()); - \Bladerunner\Config::repo([ 'view.compiled' => "{$paths['dir.upload']}/.cache", - 'view.paths' => $viewPaths, + 'view.paths' => \Bladerunner\Config::viewPaths(), ] + $paths); /** diff --git a/readme.txt b/readme.txt index 9765b8f..678b12e 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: ekandreas Tags: Blade,templates,development,laravel Requires at least: 4.4 Tested up to: 4.8.1 -Stable tag: 1.7.3 +Stable tag: 1.7.4 License: MIT WordPress plugin for Blade L5 templating diff --git a/src/Config.php b/src/Config.php index 1fcb5b9..f0ed3ab 100644 --- a/src/Config.php +++ b/src/Config.php @@ -24,4 +24,41 @@ public static function repo($key = null, $default = null) } return Container::current('config')->get($key, $default); } + + /** + * Gets all valid paths to views and templates through the installation + * @return array + */ + public static function viewPaths() + { + $bladePaths = apply_filters('bladerunner/template/bladepath', get_stylesheet_directory()); + if (!is_array($bladePaths)) { + $bladePaths = [$bladePaths]; + } + + $stylesheetPath = get_stylesheet_directory(); + $templatePath = get_template_directory(); + + $bladePaths[] = $stylesheetPath . DIRECTORY_SEPARATOR . 'views'; + $bladePaths[] = $stylesheetPath . DIRECTORY_SEPARATOR . 'views'; + + $themePaths = [ + $stylesheetPath, + $stylesheetPath . DIRECTORY_SEPARATOR . 'templates', + $templatePath, + $templatePath . DIRECTORY_SEPARATOR . 'templates', + STYLESHEETPATH, // compability + STYLESHEETPATH . DIRECTORY_SEPARATOR . 'templates', + TEMPLATEPATH, // compability + TEMPLATEPATH . DIRECTORY_SEPARATOR . 'templates', + ]; + + $bladePaths = array_merge($bladePaths, $themePaths); + + $viewPaths = array_values( + collect($bladePaths, preg_replace('%[\/]?(templates)?[\/.]*?$%', '', $bladePaths))->unique()->toArray() + ); + + return $viewPaths; + } } diff --git a/src/Container.php b/src/Container.php index 1ba9ee0..9f0b8a3 100644 --- a/src/Container.php +++ b/src/Container.php @@ -10,13 +10,13 @@ class Container extends BaseContainer * * @param string $abstract * @param array $parameters - * @param ContainerContract $container - * @return ContainerContract|mixed + * @param Container $container + * @return Container|mixed * @SuppressWarnings(PHPMD.StaticAccess) */ - public static function current($abstract = null, $parameters = [], ContainerContract $container = null) + public static function current($abstract = null, $parameters = [], Container $container = null) { - $container = $container ?: \Bladerunner\Container::getInstance(); + $container = $container ?: Container::getInstance(); if (!$abstract) { return $container; } diff --git a/src/Controller.php b/src/Controller.php index 09e6201..1b7a346 100644 --- a/src/Controller.php +++ b/src/Controller.php @@ -118,6 +118,10 @@ public function __getData() public function __getView() { + if (isset($this->template) && $this->template) { + return $this->template; + } + if (isset($this->view) && $this->view) { return $this->view; } diff --git a/src/ControllerDebug.php b/src/ControllerDebug.php index 6477531..d7b038a 100755 --- a/src/ControllerDebug.php +++ b/src/ControllerDebug.php @@ -2,6 +2,8 @@ namespace Bladerunner; +use Brain\Hierarchy\Hierarchy; + class ControllerDebug { protected $data; @@ -55,7 +57,6 @@ public function data() */ public function controller() { - // unset($this->data['post']); echo "
Controller:
    "; foreach ($this->data as $name => $item) { $item = (is_array($item) ? gettype($item) . '[' . count($item) . ']' : gettype($item)); @@ -72,10 +73,10 @@ public function controller() public function templates() { global $wp_query; - $templates = (new \Brain\Hierarchy\Hierarchy())->getTemplates($wp_query); + $templates = (new Hierarchy())->getTemplates($wp_query); echo '
    Controller Template Hierarchy (first has highest prio):
      '; foreach ($templates as $template) { - if (strpos($template, '.blade.php') || $template === 'index.php') { + if ($template === 'index.php') { continue; } if ($template === 'index') { From d82cf851e3c389cb50720417595d33dab064987d Mon Sep 17 00:00:00 2001 From: Andreas Ek Date: Fri, 27 Oct 2017 12:27:17 +0200 Subject: [PATCH 15/23] Prepp for the next release in time after 1.7.4 --- bladerunner.php | 2 +- composer.json | 2 +- readme.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bladerunner.php b/bladerunner.php index cbf4589..1fc078d 100644 --- a/bladerunner.php +++ b/bladerunner.php @@ -3,7 +3,7 @@ Plugin Name: Bladerunner Plugin URI: http://bladerunner.elseif.se Description: Laravel Blade template engine for WordPress -Version: 1.7.4 +Version: 1.7.5 Author: Andreas Ek Author URI: https://www.elseif.se/ License: MIT License diff --git a/composer.json b/composer.json index 14a5ca2..2729728 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ }, "extra": { "branch-alias": { - "dev-master": "1.7.4-dev" + "dev-master": "1.7.5-dev" } }, "minimum-stability": "dev", diff --git a/readme.txt b/readme.txt index 678b12e..7dae1b2 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: ekandreas Tags: Blade,templates,development,laravel Requires at least: 4.4 Tested up to: 4.8.1 -Stable tag: 1.7.4 +Stable tag: 1.7.5 License: MIT WordPress plugin for Blade L5 templating From 1807740697ab704df01936391ab1dbc29df009a7 Mon Sep 17 00:00:00 2001 From: fiskhandlarn Date: Mon, 30 Oct 2017 15:04:45 +0100 Subject: [PATCH 16/23] Make `bladepath` example work in strict php Issues: `bladerunner/template/bladepath` example returned undefined `$path` instead of `$paths` `bladerunner/template/bladepath` can be called with a string, the example would then choke on `$paths[] =` --- readme.md | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/readme.md b/readme.md index 8885eab..779b764 100644 --- a/readme.md +++ b/readme.md @@ -155,9 +155,12 @@ add_filter('bladerunner/cache/permission', '__return_null'); ``` If you wan't to customize the base paths where you have your views stored, use: ```php -add_filter('bladerunner/template/bladepath', function ($paths) { - $paths[] = PLUGIN_DIR . '/my-fancy-plugin/views'; - return $path; +add_filter('bladerunner/template/bladepath', function ($paths) { + if (!is_array($paths)) { + $paths = [$paths]; + } + $paths[] = ABSPATH . '../../resources/views'; + return $paths; }); ``` If you wan't to customize the controller paths where you have your controllers stored, use: From d63e0b659d48a98366bb75eae6f5d3dc15e2df43 Mon Sep 17 00:00:00 2001 From: Andreas Ek Date: Mon, 30 Oct 2017 17:30:59 +0100 Subject: [PATCH 17/23] Old filters for cache create and place restored --- globals/setup.php | 7 +++++-- readme.md | 11 +++-------- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/globals/setup.php b/globals/setup.php index 978c679..fb9fc32 100644 --- a/globals/setup.php +++ b/globals/setup.php @@ -18,7 +18,7 @@ ]; \Bladerunner\Config::repo([ - 'view.compiled' => "{$paths['dir.upload']}/.cache", + 'view.compiled' => apply_filters('bladerunner/cache/path', "{$paths['dir.upload']}/.cache"), 'view.paths' => \Bladerunner\Config::viewPaths(), ] + $paths); @@ -27,9 +27,12 @@ */ Bladerunner\Container::current()->singleton('bladerunner.blade', function (ContainerContract $app) { $cachePath = Bladerunner\Config::repo('view.compiled'); - if (!file_exists($cachePath)) { + + $makePath = apply_filters('bladerunner/cache/make', true); + if ($makePath && !file_exists($cachePath)) { wp_mkdir_p($cachePath); } + (new \Bladerunner\BladeProvider($app))->register(); return new \Bladerunner\Blade($app['view'], $app); }); diff --git a/readme.md b/readme.md index 8885eab..40cf679 100644 --- a/readme.md +++ b/readme.md @@ -143,16 +143,11 @@ add_filter('bladerunner/cache/path', function() { }); ``` -Permission settings to cache folder, default 777 +If you don't want Bladerunner to create the cache folder: ```php -add_filter('bladerunner/cache/permission', function() { - return 644; -}); -``` -If you don't want Bladerunner to check for permissions form cache folder then set the return to null, eg: -```php -add_filter('bladerunner/cache/permission', '__return_null'); +add_filter('bladerunner/cache/make', false); ``` + If you wan't to customize the base paths where you have your views stored, use: ```php add_filter('bladerunner/template/bladepath', function ($paths) { From 84aec83946701e2c93c9dfed5dd0902aae775085 Mon Sep 17 00:00:00 2001 From: Andreas Ek Date: Mon, 30 Oct 2017 17:36:02 +0100 Subject: [PATCH 18/23] Removed history from readme --- readme.md | 25 +------------------------ 1 file changed, 1 insertion(+), 24 deletions(-) diff --git a/readme.md b/readme.md index eb48cf4..69f70ac 100644 --- a/readme.md +++ b/readme.md @@ -242,27 +242,4 @@ composer update Using *Testrunner* (required-dev package) and Docker the test should be exexuted with a single command: ```bash vendor/bin/dep testrunner -``` - -## Releases - -### 1.7 -Controller concept included, read more about it at [https://bladerunner.elseif.se/controllers](https://bladerunner.elseif.se/controllers) - -### Release 1.6.1 and 1.6.2 -Just to update Laravel Blade engine upgrades - -### Release 1.6 -Laravel 5.4 with Components and Slots! -This is a completely rewrite, perhaps v2? Extracted from Roots Sage. -Some breaking changes: -* Laravel Config and View v5.4, these are in dev mode right now. -* Global function view over old global bladerunner for no echo as default. -* No template filters. You need to use "view" or "bladerunner" global functions in your ordinary WordPress templates. -* No WP admin pages, this is a dev tool :-) - -### Release 1.5 -Now only supports PHP5.6 and greater. -Laravel 5.3 is used as blade base. - - +``` \ No newline at end of file From 3721468aa598a1292ab9624bacf13dd0352344aa Mon Sep 17 00:00:00 2001 From: Andreas Ek Date: Mon, 30 Oct 2017 17:37:00 +0100 Subject: [PATCH 19/23] Removed old docs from readme, not valid --- readme.md | 51 --------------------------------------------------- 1 file changed, 51 deletions(-) diff --git a/readme.md b/readme.md index 69f70ac..4749e3d 100644 --- a/readme.md +++ b/readme.md @@ -166,59 +166,8 @@ add_filter('bladerunner/controller/paths', function ($paths) { }); ``` -#### Custom extensions -If you are comfortable with regular expressions and want to add your own extensions to your templates use the filter ``bladerunner/extend``. -Note! It takes one *array* as parameter and requires two keys; "pattern" and "replace". - -```php -$extensions[] = [ - 'pattern' => '...', - 'replace' => '...', -]; -``` - -Use the filter as possible way to add your own custom extensions. - -In this example we want to add ``@mysyntax`` as a custom extension. -```php -/* - * Add custom extension @mysyntax to Bladerunner - */ -add_filter('bladerunner/extend', function($extensions) { - $extensions[] = [ - 'pattern' => '/(\s*)@mysyntax(\s*)/', - 'replace' => '$1$2', - ]; - return $extensions; -}); -``` -Then use your new syntax inside a WordPress blade template like so: -```php - @mysyntax -``` - We will soon add more WordPress extenstions to the Bladerunner engine. Please give us your great examples to implement! -#### Template Data Filter -A simple way to pass data to a given view before it's loaded. - -Set the filter ``bladerunner/templates/data/{view}`` before running a template to pass custom data to the template, eg: -```php -$data = [ - 'this' => 'that', - 'other' => 'perhaps', -]; -add_filter('bladerunner/templates/data/single', $data); -``` - -Inside your "single.blade.php" / view file you will be able to access the passed data like so: -```php -{{ $data['this'] }} -{{ $data['other'] }} -``` - -Default value for data is an empty array. - ## Links * [Bladerunner site with documentation and distro](http://bladerunner.aekab.se) * [Docs Laravel Blade v5.2](https://laravel.com/docs/5.2/blade) From 3bcedb9d8fa6d34201437d9f05d0c38a95e14407 Mon Sep 17 00:00:00 2001 From: fiskhandlarn Date: Tue, 31 Oct 2017 13:50:09 +0100 Subject: [PATCH 20/23] Add working example for bladerunner/cache/make Issue: previous example generated this php error: `Warning: call_user_func_array() expects parameter 1 to be a valid callback, no array or string given ...` --- readme.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 4749e3d..f50f1c4 100644 --- a/readme.md +++ b/readme.md @@ -145,7 +145,9 @@ add_filter('bladerunner/cache/path', function() { If you don't want Bladerunner to create the cache folder: ```php -add_filter('bladerunner/cache/make', false); +add_filter('bladerunner/cache/make', function() { + return false; +}); ``` If you wan't to customize the base paths where you have your views stored, use: @@ -191,4 +193,4 @@ composer update Using *Testrunner* (required-dev package) and Docker the test should be exexuted with a single command: ```bash vendor/bin/dep testrunner -``` \ No newline at end of file +``` From ebd2c084b579d4f9e9fe34a2b72eb4454259265e Mon Sep 17 00:00:00 2001 From: Andreas Ek Date: Wed, 20 Dec 2017 11:57:59 +0100 Subject: [PATCH 21/23] composer adjustments for latest illuminate components --- .gitignore | 1 + composer.json | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 81b9258..79281ab 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ composer.lock phpunit.xml vendor +.idea diff --git a/composer.json b/composer.json index 2729728..8c73c7d 100644 --- a/composer.json +++ b/composer.json @@ -12,10 +12,10 @@ ], "require": { "php": "^5.6 || ^7.0", - "illuminate/config": "^5.0", - "illuminate/view": "^5.0", - "symfony/yaml": "^3.0", - "brain/hierarchy": "^2.0" + "illuminate/config": "^5", + "illuminate/view": "^5", + "symfony/yaml": "^3", + "brain/hierarchy": "^2" }, "require-dev": { "frozzare/wp-test-suite": "*" From 06cad134f1eb8f6de783807e5d2638cc984fb243 Mon Sep 17 00:00:00 2001 From: Tomas van Rijsse Date: Wed, 19 Jun 2019 12:40:01 +0200 Subject: [PATCH 22/23] add filter to disable cache and force view compilation --- readme.md | 7 +++++++ src/BladeCompiler.php | 17 +++++++++++++++++ src/BladeProvider.php | 24 ++++++++++++++++++++++++ 3 files changed, 48 insertions(+) create mode 100644 src/BladeCompiler.php diff --git a/readme.md b/readme.md index f50f1c4..f850ce6 100644 --- a/readme.md +++ b/readme.md @@ -150,6 +150,13 @@ add_filter('bladerunner/cache/make', function() { }); ``` +If you don't want Blade to use cached view files: +```php +add_filter('bladerunner/cache/disable', function() { + return true; +}); +``` + If you wan't to customize the base paths where you have your views stored, use: ```php add_filter('bladerunner/template/bladepath', function ($paths) { diff --git a/src/BladeCompiler.php b/src/BladeCompiler.php new file mode 100644 index 0000000..c824d43 --- /dev/null +++ b/src/BladeCompiler.php @@ -0,0 +1,17 @@ +app->singleton('blade.compiler', function () { + return new BladeCompiler( + $this->app['files'], $this->app['config']['view.compiled'] + ); + }); + + $resolver->register('blade', function () { + return new CompilerEngine($this->app['blade.compiler']); + }); + } } From ea3aa8ee4660c085411fe4a5654554fc0cda658b Mon Sep 17 00:00:00 2001 From: Tomas van Rijsse Date: Wed, 19 Jun 2019 12:40:49 +0200 Subject: [PATCH 23/23] remove old cache unlink function --- globals/setup.php | 5 ----- 1 file changed, 5 deletions(-) diff --git a/globals/setup.php b/globals/setup.php index fb9fc32..8dc35b6 100644 --- a/globals/setup.php +++ b/globals/setup.php @@ -49,11 +49,6 @@ } } } - - if (defined('WP_DEBUG') && WP_DEBUG) { - array_map('unlink', - glob(\Bladerunner\Config::repo('view.compiled') . '/*')); - } }); /**