c.f. http://www.web2py.com/books/default/chapter/29/05/the-views#HTML-helpers

Notice that helper attributes are passed as keyword arguments to the 
helper. In some cases, however, attribute names include special characters 
that are not allowed in Python identifiers (e.g., hyphens) and therefore 
cannot be used as keyword argument names. For example:
*DIV('text', _data-role='collapsible') *

*will not work because "_data-role" includes a hyphen, which will produce a 
Python syntax error.*

In such cases you have a couple of options. You can use the data argument 
(this time without a leading underscore) to pass a dictionary of related 
attributes without their leading hyphen, and the output will have the 
desired combinations e.g.
>>> print DIV('text', *data={'role': 'collapsible'}*)
<div data-role="collapsible">text</div> 

or you can instead pass the attributes as a dictionary and make use of 
Python's ** function arguments notation, which maps a dictionary of 
(key:value) pairs into a set of keyword arguments:
>>> print DIV('text', **{'_data-role': 'collapsible'})
<div data-role="collapsible">text</div> 

Regards
Clemens

On Thursday, July 27, 2023 at 7:46:24 AM UTC+2 [email protected] wrote:

How do we achieve this using the BUTTON() helper

<button class="btn btn-secondary dropdown-toggle" type="button" id=
"dropdownMenuButton" data-toggle="dropdown">

I am having trouble with the "data-toggle" attribute.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/36950964-fbee-40dc-b829-5ef98704826dn%40googlegroups.com.

Reply via email to