'Handles Template:Template name, formatting the content using given
args'

def _hook_template(self, parser, space, title):

    params = title.split('|')
    short_title = params.pop(0)
    template_title = ('Template:' + short_title)
    message = (_('The    template    "%s"    does    not    exist    or    has    no    approved    revision.') % short_title)
    template = get_object_fallback(Document, template_title, locale=self.locale, is_template=True)
    if ((not template) or (not template.current_revision)):
        return message
    if (template.id in parser.inclusions):
        return (RECURSION_MESSAGE % template_title)
    else:
        parser.inclusions.append(template.id)
    c = template.current_revision.content.rstrip()
    parsed = parser.parse(c, show_toc=False, attributes=ALLOWED_ATTRIBUTES, locale=self.locale)
    parser.inclusions.pop()
    if ('\n' not in c):
        parsed = parsed.replace('<p>', '')
        parsed = parsed.replace('</p>', '')
    return _format_template_content(parsed, _build_template_params(params))
