Skip to content

Commit

Permalink
Bladerunner helper added
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas Ek committed Jan 28, 2016
1 parent 70e2aaa commit 5fe7d6d
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
20 changes: 19 additions & 1 deletion bladerunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Bladerunner
Plugin URI: http://bladerunner.aekab.se
Description: Laravel Blade template engine for WordPress
Version: 1.0.7
Version: 1.0.8
Author: Andreas Ek
Author URI: http://www.aekab.se/
License: MIT License
Expand All @@ -25,3 +25,21 @@

register_activation_hook(__FILE__, '\Bladerunner\init::createCacheDirectory');
register_deactivation_hook(__FILE__, '\Bladerunner\init::deleteCacheDirectory');

/**
* Check if global helper function could be declared
*/
if (!function_exists('bladerunner')) {
/**
* Global helper function to use in templates to render correct view
* This will use the Illuminate Blade engine to render correct view in a standard WordPress template
* @param string $view Name of the view with path, eg: views.pages.single
* @param array $data Any object data to use in the view template/file
* @return void
*/
function bladerunner($view, $data = [])
{
$blade = new \Bladerunner\Blade(get_stylesheet_directory(), \Bladerunner\Cache::path());
echo $blade->view()->make($view, $data)->render();
}
}
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "ekandreas/bladerunner",
"type": "wordpress-plugin",
"version": "1.0.7",
"version": "1.0.8",
"description": "WordPress Blade L5 template engine",
"keywords": ["laravel", "blade", "wordpress"],
"license": "MIT",
Expand Down
27 changes: 26 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Bladerunner

[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://packagist.org/packages/ekandreas/bladerunner)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/ekandreas/bladerunner)
[![Build Status](https://travis-ci.org/ekandreas/bladerunner.svg?branch=master)](https://travis-ci.org/ekandreas/bladerunner)
[![StyleCI](https://styleci.io/repos/48002506/shield)](https://styleci.io/repos/48002506)
[![GitHub release](https://img.shields.io/github/release/ekandreas/bladerunner.svg)](http://bladerunner.aekab.se/bladerunner.zip)
Expand Down Expand Up @@ -42,6 +42,31 @@ https://laravel.com/docs/5.2/blade
* Your views must be placed within your theme folder.
* Your templates must have .blade.php extension.

## Template helper
There is a template helper function named "bladerunner", defined globally to use in standard WordPress templates.

Example:
You want to create a 404-template and don't want to use the .blade.php extension to the template file.

* Create a 404.php in the theme root.
* Add the following code to the template:
```
<?php
bladerunner('views.pages.404');
```
* In the folder "views/pages", create a blade template "404.blade.php".

You can pass any data with the global "bladerunner" function like so,
```
<?php
bladerunner('views.pages.404', ['module'=>$module]);
```
or use compact, eg:
```
<?php
bladerunner('views.pages.404', compact('module'));
```

## Hooks & Filters
Bladerunner continuously implements filters and hooks to modify values and processes.

Expand Down
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Contributors: ekandreas
Tags: Blade,templates,development,laravel
Requires at least: 4.4
Tested up to: 4.4
Stable tag: 1.0.7
Stable tag: 1.0.8
License: MIT

WordPress plugin for Blade L5 templating
Expand Down

0 comments on commit 5fe7d6d

Please sign in to comment.