protected function render($type, array $data = [])
    {
        $templateName = empty($data['title']) ? $type.'_notitle' : $type;
        $template = $this->templates[$templateName];

        if (is_callable($template)) {
            return $template($data);
        } else {
            $replace = array();

            foreach ($data as $key => $value) {
                $replace['{'.$key.'}'] = $key != 'html' ? $this->escapeHtml($value) : (string) $value;
            }

            return strtr($template, $replace);
        }
    }