<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def template(template_name):
 """Return a jinja template ready for rendering. If needed, global variables are initialized. Parameters template_name: str, the name of the template as defined in the templates mapping Returns ------- The Jinja template ready for rendering """

    globals = None
    if template_name.startswith('row_'):
        # This is a row template setting global variable
        globals = dict()
        globals['vartype'] = var_type[template_name.split('_')[1].upper()]
    return jinja2_env.get_template(templates[template_name], globals=globals)