Changeset 371
- Timestamp:
- Oct 16, 2006, 10:11:47 AM (17 years ago)
- Location:
- branches/stable/0.3.x/genshi
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/stable/0.3.x/genshi/template.py
r366 r371 1341 1341 1342 1342 search_path = self.search_path 1343 isabs = False 1343 1344 1344 1345 if os.path.isabs(filename): 1345 1346 # Bypass the search path if the requested filename is absolute 1346 1347 search_path = [os.path.dirname(filename)] 1348 isabs = True 1347 1349 1348 1350 elif relative_to and os.path.isabs(relative_to): … … 1351 1353 dirname = os.path.dirname(relative_to) 1352 1354 if dirname not in search_path: 1353 search_path = search_path[:] + [dirname] 1355 search_path = search_path + [dirname] 1356 isabs = True 1354 1357 1355 1358 elif not search_path: … … 1362 1365 fileobj = open(filepath, 'U') 1363 1366 try: 1367 if isabs: 1368 # If the filename of either the included or the 1369 # including template is absolute, make sure the 1370 # included template gets an absolute path, too, 1371 # so that nested include work properly without a 1372 # search path 1373 filename = os.path.join(dirname, filename) 1374 dirname = '' 1364 1375 tmpl = cls(fileobj, basedir=dirname, filename=filename, 1365 1376 loader=self) -
branches/stable/0.3.x/genshi/tests/template.py
r357 r371 1175 1175 </html>""", tmpl.generate().render()) 1176 1176 1177 def test_relative_include_without_search_path_nested(self): 1178 file1 = open(os.path.join(self.dirname, 'tmpl1.html'), 'w') 1179 try: 1180 file1.write("""<div>Included</div>""") 1181 finally: 1182 file1.close() 1183 1184 file2 = open(os.path.join(self.dirname, 'tmpl2.html'), 'w') 1185 try: 1186 file2.write("""<div xmlns:xi="http://www.w3.org/2001/XInclude"> 1187 <xi:include href="tmpl1.html" /> 1188 </div>""") 1189 finally: 1190 file2.close() 1191 1192 file3 = open(os.path.join(self.dirname, 'tmpl3.html'), 'w') 1193 try: 1194 file3.write("""<html xmlns:xi="http://www.w3.org/2001/XInclude"> 1195 <xi:include href="tmpl2.html" /> 1196 </html>""") 1197 finally: 1198 file3.close() 1199 1200 loader = TemplateLoader() 1201 tmpl = loader.load(os.path.join(self.dirname, 'tmpl3.html')) 1202 self.assertEqual("""<html> 1203 <div> 1204 <div>Included</div> 1205 </div> 1206 </html>""", tmpl.generate().render()) 1207 1177 1208 def test_relative_include_from_inmemory_template(self): 1178 1209 file1 = open(os.path.join(self.dirname, 'tmpl1.html'), 'w')
Note: See TracChangeset
for help on using the changeset viewer.