def add_class(add, class_):
    """Add to a CSS class attribute.

    The string `add` will be added to the classes already in `class_`, with
    a space if needed.  `class_` can be None::

        >>> add_class("foo", None)
        'foo'
        >>> add_class("foo", "bar")
        'bar foo'

    Returns the amended class string.

    """
    if class_:
        class_ += " "
    else:
        class_ = ""
    return class_ + add