/** * @param $string * @param array $context * @param null|callable $exceptionHandler * @return string */ public function parse($string, $context = array(), $exceptionHandler = null) { if (!empty($string)) { try { if ($this->_env->getLoader() instanceof IfwPsn_Vendor_Twig_Loader_String) { $string = $this->_sanitzeString($string); } $string = $this->_env->render($string, $context); } catch (Exception $e) { // invalid filter handling if (is_callable($exceptionHandler)) { call_user_func_array($exceptionHandler, array($e)); } else { if ($this->_logger instanceof IfwPsn_Wp_Plugin_Logger) { $this->_logger->err($e->getMessage()); } } } } return $string; }