Skip to content

Instantly share code, notes, and snippets.

@tobsn
Created December 16, 2010 01:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tobsn/742905 to your computer and use it in GitHub Desktop.
Save tobsn/742905 to your computer and use it in GitHub Desktop.
blitz template engine view class for slim framework
<?php
// extended blitz class for better block handling (load assoc arrays correctly, one level)
class xBlitz extends Blitz{function xblock($k,$a){foreach($a as $v){$this->block('/'.$k,$v,true);}}}
class BlitzView extends View {
private $blitzEnvironment = null;
public function render( $template ) {
$env = $this->getEnvironment( $template );
return $env->parse( $this->data );
}
private function getEnvironment( $template ) {
if ( !$this->blitzEnvironment ) {
ini_set( 'blitz.path', $this->getTemplatesDirectory().'/' );
$this->blitzEnvironment = new xBlitz( $template );
}
return $this->blitzEnvironment;
}
}
?>
@codeguy
Copy link

codeguy commented Dec 18, 2010

This has been added to the Slim develop branch. Will be merged into master when 1.1 is complete.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment