Generate ``.wfind()`` call for HTMLElement.

    Args:
        use_dom (bool): Use ``dom`` as tag name. If ``False``, ``el`` is used.
        parameters (list): List of parameters for ``.wfind()``.
        index (int): Index of the item you want to get from ``.wfind()`` call.
        required (bool, default False): Use :func:`_required_idiom` to returned
                 data.
        notfoundmsg (str, default None): Message which will be used for
                    :func:`_required_idiom` if the item is not found.

    Returns:
        str: Python code.

    Live example::
        >>> print g._wfind_template(True, ["<xex>"], 3)
            el = dom.wfind('<xex>').childs
            # pick element from list
            el = el[3] if len(el) - 1 >= 3 else None

def _wfind_template(use_dom, parameters, index, required=False,
                                                notfoundmsg=None):
    """
    Generate ``.wfind()`` call for HTMLElement.

    Args:
        use_dom (bool): Use ``dom`` as tag name. If ``False``, ``el`` is used.
        parameters (list): List of parameters for ``.wfind()``.
        index (int): Index of the item you want to get from ``.wfind()`` call.
        required (bool, default False): Use :func:`_required_idiom` to returned
                 data.
        notfoundmsg (str, default None): Message which will be used for
                    :func:`_required_idiom` if the item is not found.

    Returns:
        str: Python code.

    Live example::
        >>> print g._wfind_template(True, ["<xex>"], 3)
            el = dom.wfind('<xex>').childs
            # pick element from list
            el = el[3] if len(el) - 1 >= 3 else None
    """
    tag_name = "dom" if use_dom else "el"
    output = IND + "el = %s.wfind(%s).childs\n\n" % (
        tag_name,
        repr(parameters)[1:-1]
    )

    if required:
        return output + _required_idiom(parameters[0], index, notfoundmsg)

    return output + _index_idiom("el", index)