From 1c11a941ca832c06ba125e1da226030504c58033 Mon Sep 17 00:00:00 2001 From: Joshua Harlow Date: Mon, 11 Jun 2012 17:18:37 -0700 Subject: Start using tempita instead of the more complicated cheetah. --- cloudinit/templater.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'cloudinit') diff --git a/cloudinit/templater.py b/cloudinit/templater.py index 04cc5a6f..5839911c 100644 --- a/cloudinit/templater.py +++ b/cloudinit/templater.py @@ -20,15 +20,22 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . -from Cheetah.Template import Template +from tempita import Template from cloudinit import util -def render_to_file(template_fn, outfile, searchList): - contents = Template(file=template_fn, searchList=[searchList]).respond() +def render_from_file(fn, params): + return render_string(util.load_file(fn), params, name=fn) + + +def render_to_file(name, outfile, params): + contents = render_from_file(name, params) util.write_file(outfile, contents) -def render_string(template, searchList): - return Template(template, searchList=[searchList]).respond() +def render_string(content, params, name=None): + tpl = Template(content, name=name) + if not params: + params = dict() + return tpl.substitute(params) -- cgit v1.2.3