Created
December 8, 2011 22:30
-
-
Save chucktrukk/1448976 to your computer and use it in GitHub Desktop.
quick method to send class to twig
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 | |
class AnyClassUsa { | |
public function render($template) | |
{ | |
$twig = $this->twig; | |
foreach(get_object_vars($this) as $property => $value) { | |
$params[$property] = $value; | |
} | |
$params['this'] = $this; | |
try { | |
$template = $twig->loadTemplate($template); | |
} catch(Exception $e) { | |
return "Unable to find template '{$template}'"; | |
return $e->getMessage(); | |
} | |
try { | |
return $template->render($params); | |
} catch(Exception $e) { | |
return $e->getMessage(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment