diff --git a/formwork/Template/Renderer.php b/formwork/Template/Renderer.php new file mode 100644 index 00000000..833705ad --- /dev/null +++ b/formwork/Template/Renderer.php @@ -0,0 +1,50 @@ +getClosure($instance, $context); + return $closure($filename, $vars); + } + + /** + * Return rendering closure bound to given instance and context + * + * @param object $instance + * @param string|null $context + * + * @return Closure + */ + protected function getClosure($instance, $context = null) + { + return Closure::bind(function ($_filename, array $_vars) { + extract($_vars); + return include $_filename; + }, $instance, $context); + } +}