def _render_object(self, obj, *context, **kwargs): """ Render the template associated with the given object. """ loader = self._make_loader() # TODO: consider an approach that does not require using an if # block here. For example, perhaps this class's loader can be # a SpecLoader in all cases, and the SpecLoader instance can # check the object's type. Or perhaps Loader and SpecLoader # can be refactored to implement the same interface. if isinstance(obj, TemplateSpec): loader = SpecLoader(loader) template = loader.load(obj) else: template = loader.load_object(obj) context = [obj] + list(context) return self._render_string(template, *context, **kwargs)