Dom

The DOM string returned by the render_function of Component and Layout are wrapped under some custom tags. But in case you want the plain DOM to be streamed then this class comes into picture.

The Dom Class

Dom is a class that holds the information which is used for rendering it on client. To be more precise, it stores the function and arguments that when called returns the DOM string which needs to be rendered on client.

class flasksr.Dom(render_function, *args, **kwargs)

Parameters:

  • render_function: is the function that returns the DOM String. In case there are any args or kwargs to the render_function, you can directly pass them into constructor of Dom. Thus we say that, the constructor also accepts args and kwargs which are passed directly to the render_function.

Sample Dom object: menu

def render_menu():
    return """
        <ul style="list-style-type: none; margin: 0; padding: 0;">
            <li><a href="/">Home</a></li>
            <li><a href="#">News</a></li>
            <li><a href="#">Contact</a></li>
            <li><a href="#">About</a></li>
        </ul>
    """

d = Dom(render_menu)

results matching ""

    No results matching ""