<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def dump_to_template_obj(self, stack, t):
 """ Add resource definitions to the given template object """

        if len(self.Parameters) > 0:
            t['Parameters'] = dict([e.contents(stack) for e in self.Parameters])
        if len(self.Mappings) > 0:
            t['Mappings'] = dict([e.contents(stack) for e in self.Mappings])
        if len(self.Resources) > 0:
            t['Resources'] = dict([e.contents(stack) for e in self.Resources])
        if len(self.Outputs) > 0:
            t['Outputs'] = dict([e.contents(stack) for e in self.Outputs])