MCPcopy Create free account
hub / github.com/PageBot/PageBot / addTemplate

Method addTemplate

Lib/pagebot/document.py:346–361  ·  view source on GitHub ↗

Adds the template to the self.templates of dictionaries. There is no check, so the calling function can overwrite existing templates. Answer the template. >>> name ='TestTemplate' >>> t = Template(w=200, h=300, name=name) >>> doc = Document(name='TestDoc')

(self, name, template)

Source from the content-addressed store, hash-verified

344 return self.templates.get(name, self.defaultTemplate)
345
346 def addTemplate(self, name, template):
347 """Adds the template to the self.templates of dictionaries. There is no
348 check, so the calling function can overwrite existing templates. Answer the
349 template.
350
351 >>> name ='TestTemplate'
352 >>> t = Template(w=200, h=300, name=name)
353 >>> doc = Document(name='TestDoc')
354 >>> doc.addTemplate('myTemplate', t)
355 <Template>
356 >>> doc.getTemplate('myTemplate').name == name
357 True
358 """
359 template.parent = self
360 self.templates[name] = template
361 return template
362
363 def _get_defaultTemplate(self):
364 """Answers the default template of the document.

Callers 3

initializeTemplatesMethod · 0.95
_set_defaultTemplateMethod · 0.95
makeTemplateMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected