Skip to content

Instantly share code, notes, and snippets.

@paulschwarz
Created August 26, 2013 11:02
Show Gist options
  • Save paulschwarz/6340325 to your computer and use it in GitHub Desktop.
Save paulschwarz/6340325 to your computer and use it in GitHub Desktop.
<?php
class Kostache_Page extends Kostache_Base {
/**
* @return Kostache_Page
*/
public static function factory()
{
$m = new Mustache_Engine(
array(
'loader' => new Mustache_Loader_Kohana(),
'partials_loader' => new Mustache_Loader_Kohana('templates/partials'),
'escape' => function($value) {
return HTML::chars($value);
},
'cache' => APPPATH.'cache/mustache',
)
);
$class = get_called_class();
return new $class($m);
}
public function render($class, $template = NULL)
{
$content = parent::render($class, $template);
return str_replace([
'[[assets_head]]',
'[[assets_body]]',
'</form>',
], [
$class->assets_head(),
$class->assets_body(),
Form::hidden('csrf', Security::token())."\n".'</form>',
], $content);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment