def test_button_with_illegal_type(self): try: self.assertEqual( render_button("button", button_type="illegal"), '<button class="btn btn-primary">button</button>') except BootstrapError as e: self.assertEqual( str(e), 'Parameter "button_type" should be "submit", "reset", "button", "link" or empty ("illegal" given).', )
def bootstrap_button(*args, **kwargs): """ Render a button **Tag name**:: bootstrap_button **Parameters**: content The text to be displayed in the button button_type Optional field defining what type of button this is. Accepts one of the following values: * ``'submit'`` * ``'reset'`` * ``'button'`` * ``'link'`` icon Name of an icon to render in the button's visible content. See bootstrap_icon_ for acceptable values. button_class Any extra CSS classes that should be added to the button. size Optional field to control the size of the button. Accepts one of the following values: * ``'xs'`` * ``'sm'`` * ``'small'`` * ``'md'`` * ``'medium'`` * ``'lg'`` * ``'large'`` href Render the button as an ``<a>`` element. The ``href`` attribute is set with this value. name Value of the ``name`` attribute of the rendered element. value Value of the ``value`` attribute of the rendered element. **Usage**:: {% bootstrap_button content %} **Example**:: {% bootstrap_button "Save" button_type="submit" button_class="btn-primary" %} """ return render_button(*args, **kwargs)
def test_button(self): self.assertEqual(render_button("button"), '<button class="btn btn-primary">button</button>')