Created
June 20, 2013 20:52
-
-
Save JesseObrien/5826525 to your computer and use it in GitHub Desktop.
Laravel 3 Hack views to render from string instead of file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Mynamespace; | |
class Blade extends \Laravel\Blade | |
{ | |
public static function compile($content) { | |
return static::compile_string($content); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Mynamespace; | |
use Mynamespace\Blade; | |
class View extends \Laravel\View { | |
protected $payload = null; | |
public function __construct($payload, $data = array()) | |
{ | |
$this->payload = $payload; | |
parent::__construct(null, $data); | |
} | |
/** | |
* To avoid the path not existing, just return true | |
*/ | |
public function path($view) | |
{ | |
return true; | |
} | |
/** | |
* Content will be rendered by the custom blade we have in our namespace as well. | |
*/ | |
protected function load() | |
{ | |
return Blade::compile($this->payload); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment