/** * A function for rendering a template through calling the TwigPress Class * * @param array $vals An array of variables to be rendered with the template, defaults to an empty array * @param string $template The name of the template to be rendered, if users want to override the default action, defaults to false * @param bool $echo A boolean indicating whether to echo or return the rendered template, defaults to true * * @return string The rendered template */ function twigpress_render_twig_template($vals = array(), $template = false, $echo = true) { $TwigPress = TwigPress::get_instance(); # If no template has been specified, look for {PHP Template Filename}.twig if (false == $template) { $template = pathinfo(basename($TwigPress::$template), PATHINFO_FILENAME) . '.twig'; } # Check whether we are echoing or returning if (true == $echo) { echo $TwigPress->render_template($template, $vals); } else { return $TwigPress->render_template($template, $vals); } }