| 100 | def render_to_file(template_name, file_path, mode='w', dictionary=None, context_instance=None): |
| 101 | """ |
| 102 | Loads the given template_name and renders it, with the given dictionary as |
| 103 | context, to a file on disk. The template_name may be a string to load a |
| 104 | single template using get_template, or it may be a tuple to use |
| 105 | select_template to find one of the templates in the list. file_path defines |
| 106 | the file that will be written to disk. mode defaults to 'w' which will |
| 107 | create the file if it doesn't exist and will overwrite the file if it does |
| 108 | exist. |
| 109 | """ |
| 110 | f = open(file_path, mode) |
| 111 | f.write(render_to_string(template_name, dictionary, context_instance)) |
| 112 | f.close() |
| 113 | |