def sub_template(template_file, items):
    """replace some set of key/value pairs in a
    template file (inplace) with the expectation
    that a key should be within {{ }}"""
    with open(template_file, 'r') as filey:
        content = filey.read()
        for key, val in items.items():
            key = '{{ %s }}' % key
            content = content.replace(key, val)
    with open(template_file, 'w') as filey:
        filey.writelines(content)
    return template_file
