Example #1
0
    def __str__(self):
        """Convert object into string.

        Returns HTML container of the button that can be embedded in the website."""
        attributes = self.attributes

        class_parts = [self.ATTR_CLASS]
        if attributes.get('class'):
            class_parts.append(attributes['class'])

        class_parts.append(self.ATTR_CLASS_SIZE_PREFIX + self.get_size())
        class_parts.append(self.ATTR_CLASS_COLOR_PREFIX + self.get_color())

        attributes['class'] += ' '.join(class_parts)

        if self.get_label():
            attributes['title'] = self.get_label()

        result = '<div {0}>{1}</div>'.format(
            ' '.join([
                '{0}="{1}"'.format(key, htmlspecialchars(value))
                for key, value in attributes
            ]), self.get_content())

        return result
Example #2
0
    def __str__(self):
        """Convert object into string.

        Returns HTML container of the button that can be embedded in the website."""
        attributes = self.attributes

        class_parts = [self.ATTR_CLASS]
        if attributes.get("class"):
            class_parts.append(attributes["class"])

        class_parts.append(self.ATTR_CLASS_SIZE_PREFIX + self.get_size())
        class_parts.append(self.ATTR_CLASS_COLOR_PREFIX + self.get_color())

        attributes["class"] += " ".join(class_parts)

        if self.get_label():
            attributes["title"] = self.get_label()

        result = "<div {0}>{1}</div>".format(
            " ".join(['{0}="{1}"'.format(key, htmlspecialchars(value)) for key, value in attributes]),
            self.get_content(),
        )

        return result
Example #3
0
 def create_attributes_string(self, attrs):
     """Creates HTML attributes string."""
     escaped = lambda key, value: '{0}="{1}"'.format(htmlspecialchars(key), htmlspecialchars(value))
     return ' '.join([escaped(key, value) for key, value in six.iteritems(attrs)])