def render_template_inplace(template_path, info, dry_run=False, extra_filters=None, resolver=None):
    """Render a template file in place.

    This function expects template path to be a path to a file
    that ends in .tpl.  It will be rendered to a file in the
    same directory with the .tpl suffix removed.

    Args:
        template_path (str): The path to the template file
            that we want to render in place.
        info (dict): A dictionary of variables passed into the template to
            perform substitutions.
        dry_run (bool): Whether to actually render the output file or just return
            the file path that would be generated.
        extra_filters (dict of str -> callable): An optional group of filters that
            will be made available to the template.  The dict key will be the
            name at which callable is made available.
        resolver (ProductResolver): The specific ProductResolver class to use in the
            find_product filter.

    Returns:
        str: The path to the output file generated.
    """

    filters = {}
    if resolver is not None:
        filters['find_product'] = _create_resolver_filter(resolver)

    if extra_filters is not None:
        filters.update(extra_filters)

    basedir = os.path.dirname(template_path)
    template_name = os.path.basename(template_path)

    if not template_name.endswith('.tpl'):
        raise ArgumentError("You must specify a filename that ends in .tpl", filepath=template_path)

    out_path = os.path.join(basedir, template_name[:-4])

    if basedir == '':
        basedir = '.'

    env = Environment(loader=FileSystemLoader(basedir),
                      trim_blocks=True, lstrip_blocks=True)

    # Load any filters the user wants us to use
    for name, func in filters.items():
        env.filters[name] = func

    template = env.get_template(template_name)
    result = template.render(info)

    if not dry_run:
        with open(out_path, 'wb') as outfile:
            outfile.write(result.encode('utf-8'))

    return out_path
def render_template_inplace ( template_path , info , dry_run = False , extra_filters = None , resolver = None ) : filters = { } if resolver is not None : filters [ 'find_product' ] = _create_resolver_filter ( resolver ) if extra_filters is not None : filters . update ( extra_filters ) basedir = os . path . dirname ( template_path ) template_name = os . path . basename ( template_path ) if not template_name . endswith ( '.tpl' ) : raise ArgumentError ( "You must specify a filename that ends in .tpl" , filepath = template_path ) out_path = os . path . join ( basedir , template_name [ : - 4 ] ) if basedir == '' : basedir = '.' env = Environment ( loader = FileSystemLoader ( basedir ) , trim_blocks = True , lstrip_blocks = True ) for name , func in filters . items ( ) : env . filters [ name ] = func template = env . get_template ( template_name ) result = template . render ( info ) if not dry_run : with open ( out_path , 'wb' ) as outfile : outfile . write ( result . encode ( 'utf-8' ) ) return out_path
Render a template file in place.

    This function expects template path to be a path to a file
    that ends in .tpl.  It will be rendered to a file in the
    same directory with the .tpl suffix removed.

    Args:
        template_path (str): The path to the template file
            that we want to render in place.
        info (dict): A dictionary of variables passed into the template to
            perform substitutions.
        dry_run (bool): Whether to actually render the output file or just return
            the file path that would be generated.
        extra_filters (dict of str -> callable): An optional group of filters that
            will be made available to the template.  The dict key will be the
            name at which callable is made available.
        resolver (ProductResolver): The specific ProductResolver class to use in the
            find_product filter.

    Returns:
        str: The path to the output file generated.