Skip to content

Instantly share code, notes, and snippets.

@JesseObrien
Created June 20, 2013 20:52
Show Gist options
  • Save JesseObrien/5826525 to your computer and use it in GitHub Desktop.
Save JesseObrien/5826525 to your computer and use it in GitHub Desktop.
Laravel 3 Hack views to render from string instead of file.
<?php
namespace Mynamespace;
class Blade extends \Laravel\Blade
{
public static function compile($content) {
return static::compile_string($content);
}
}
<?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