def render(self, context): option_name = self.option_name.resolve(context) options = OptionsAPI.by_slug(option_name) widgets = [] for option in options: widgets.append(option.value.strip()) return ''.join(widgets)
def render(self, context): object = self.object.resolve(context) option_name = self.option_name.resolve(context) # Let's loop though all the object attributes and form a formatting # dict by tag name with their values. We'll use this for replacements. context = {} for tag in dir(object): if not tag.startswith('_'): try: context[tag] = getattr(object, tag) except AttributeError: pass cx = template.Context(context) # Get the social options options = OptionsAPI.by_slug(option_name) widgets = [] for option in options: tp = template.Template(option.value.strip()) widgets.append(tp.render(cx)) return ''.join(widgets)