Example #1
0
 def save(self):
     if self.default:
         raise Exception
     
     super(Template, self).save()
     if self.tpl == '':
         self.tpl = str(self.id) + '.tpl'
         super(Template, self).save()
         
     r = MultiReplace({'{': '{ldelim}', '}': '{rdelim}'})
     outhtml = r.replace(self.html)
     
     try:
         stylepos = outhtml.index('</style>')
         pos = stylepos + '</style>'.__len__()
     except ValueError:
         pos = 0
 
     outfile = '/home/widget/smarty/templates/' + self.tpl
     f = open(outfile, 'w')
     f.write(outhtml[0:pos] + '<div id="widget">{section name=i loop=$feeds}' 
             + outhtml[pos + 1:] + '{/section}</div>')
     f.close()
     os.chmod(outfile, 0666)
Example #2
0
 def clean_html(self):
     r = MultiReplace({'<?': '&lt;?', '<%=': '&lt;%='})
     return r.replace(self.cleaned_data['html'].strip())