Example #1
0
    def __call__(self, **kwargs):
        """
        Generate the HTML code of the current widget. Keyword arguments are
        used to format the generated HTML.

            >>> a = DemoWidget('hello.world', '{name}')
            >>> a(name='demo')
            '<input name="demo" ng-model="hello.world"/>
        """
        for modifier in self.modifiers:
            if hasattr(modifier, 'attributes'):
                self.html_attributes.update(modifier.attributes)
        template = Template(self.html_template).render(widget=self)
        return HTMLString(template.strip().format(**kwargs))
Example #2
0
class TestHtml(object):
    def setup(self):

        self.html = HTMLString(u'hello')

    def test_0(self):
        """An HTMLString object is an unicode subtype"""
        assert_true(isinstance(self.html, unicode))

    def test_1(self):
        """An HTMLString object is __html__."""
        assert_true(hasattr(self.html, '__html__'))

    def test_2(self):
        """The __html__ method return the unicode string."""
        assert_equal(self.html.__html__(), self.html)
Example #3
0
class TestHtml(object):

    def setup(self):

        self.html = HTMLString(u'hello')

    def test_0(self):
        """An HTMLString object is an unicode subtype"""
        assert_true(isinstance(self.html, unicode))

    def test_1(self):
        """An HTMLString object is __html__."""
        assert_true(hasattr(self.html, '__html__'))

    def test_2(self):
        """The __html__ method return the unicode string."""
        assert_equal(self.html.__html__(), self.html)
Example #4
0
    def setup(self):

        self.html = HTMLString(u'hello')
Example #5
0
    def setup(self):

        self.html = HTMLString(u'hello')