﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
1169	[patch] Render a template to a file on disk (loader.render_to_disk)	eric@…	Adrian Holovaty	"Here's a patch that allows one to render (output, save) a template to a file on disk.  Use it in a similar way as you would use loader.render_to_string().


render_to_file loads the given template_name and renders it, with the given dictionary as context, to a file on disk.  The template_name may be a string to load a single template using get_template, or it may be a tuple to use select_template to find one of the templates in the list.  file_path defines the file that will be written to disk.  mode defaults to 'w' which will create the file if it doesn't exist and will overwrite the file if it does exist.


Here's an example use:

{{{
from django.core.template import loader


path = '/path/to/my/file.txt'
template = 'django/path/to/template/name'
loader.render_to_file(template_name=template,
                      file_path=path,
                      dictionary={'foo': self.get_foo(),
                                  'bar': Bar(),})
}}}
"	enhancement	closed	Template system		normal	wontfix	loader, render_to_disk, render_to_string		Ready for checkin	1	0	0	0	0	0
