Changeset 370
- Timestamp:
- Oct 16, 2006, 10:08:13 AM (17 years ago)
- Location:
- trunk/genshi
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/genshi/plugin.py
r369 r370 52 52 max_cache_size) 53 53 54 self.loader = TemplateLoader(search_path, auto_reload=auto_reload, 54 self.loader = TemplateLoader(filter(None, search_path), 55 auto_reload=auto_reload, 55 56 max_cache_size=max_cache_size) 56 57 -
trunk/genshi/template.py
r365 r370 1355 1355 1356 1356 search_path = self.search_path 1357 isabs = False 1357 1358 1358 1359 if os.path.isabs(filename): 1359 1360 # Bypass the search path if the requested filename is absolute 1360 1361 search_path = [os.path.dirname(filename)] 1362 isabs = True 1361 1363 1362 1364 elif relative_to and os.path.isabs(relative_to): … … 1365 1367 dirname = os.path.dirname(relative_to) 1366 1368 if dirname not in search_path: 1367 search_path = search_path[:] + [dirname] 1369 search_path = search_path + [dirname] 1370 isabs = True 1368 1371 1369 1372 elif not search_path: … … 1376 1379 fileobj = open(filepath, 'U') 1377 1380 try: 1381 if isabs: 1382 # If the filename of either the included or the 1383 # including template is absolute, make sure the 1384 # included template gets an absolute path, too, 1385 # so that nested include work properly without a 1386 # search path 1387 filename = os.path.join(dirname, filename) 1388 dirname = '' 1378 1389 tmpl = cls(fileobj, basedir=dirname, filename=filename, 1379 1390 loader=self) -
trunk/genshi/tests/template.py
r365 r370 1236 1236 </html>""", tmpl.generate().render()) 1237 1237 1238 def test_relative_include_without_search_path_nested(self): 1239 file1 = open(os.path.join(self.dirname, 'tmpl1.html'), 'w') 1240 try: 1241 file1.write("""<div>Included</div>""") 1242 finally: 1243 file1.close() 1244 1245 file2 = open(os.path.join(self.dirname, 'tmpl2.html'), 'w') 1246 try: 1247 file2.write("""<div xmlns:xi="http://www.w3.org/2001/XInclude"> 1248 <xi:include href="tmpl1.html" /> 1249 </div>""") 1250 finally: 1251 file2.close() 1252 1253 file3 = open(os.path.join(self.dirname, 'tmpl3.html'), 'w') 1254 try: 1255 file3.write("""<html xmlns:xi="http://www.w3.org/2001/XInclude"> 1256 <xi:include href="tmpl2.html" /> 1257 </html>""") 1258 finally: 1259 file3.close() 1260 1261 loader = TemplateLoader() 1262 tmpl = loader.load(os.path.join(self.dirname, 'tmpl3.html')) 1263 self.assertEqual("""<html> 1264 <div> 1265 <div>Included</div> 1266 </div> 1267 </html>""", tmpl.generate().render()) 1268 1238 1269 def test_relative_include_from_inmemory_template(self): 1239 1270 file1 = open(os.path.join(self.dirname, 'tmpl1.html'), 'w')
Note: See TracChangeset
for help on using the changeset viewer.