def register_asset(self, type_, *assets):
        """Register webassets bundle to be served on all pages.

        :param type_: `"css"`, `"js-top"` or `"js""`.

        :param assets:
            a path to file, a :ref:`webassets.Bundle <webassets:bundles>`
            instance or a callable that returns a
            :ref:`webassets.Bundle <webassets:bundles>` instance.

        :raises KeyError: if `type_` is not supported.
        """
        supported = list(self._assets_bundles.keys())
        if type_ not in supported:
            msg = "Invalid type: {}. Valid types: {}".format(
                repr(type_), ", ".join(sorted(supported))
            )
            raise KeyError(msg)

        for asset in assets:
            if not isinstance(asset, Bundle) and callable(asset):
                asset = asset()

            self._assets_bundles[type_].setdefault("bundles", []).append(asset)
def register_asset ( self , type_ , * assets ) : supported = list ( self . _assets_bundles . keys ( ) ) if type_ not in supported : msg = "Invalid type: {}. Valid types: {}" . format ( repr ( type_ ) , ", " . join ( sorted ( supported ) ) ) raise KeyError ( msg ) for asset in assets : if not isinstance ( asset , Bundle ) and callable ( asset ) : asset = asset ( ) self . _assets_bundles [ type_ ] . setdefault ( "bundles" , [ ] ) . append ( asset )
Register webassets bundle to be served on all pages.

        :param type_: `"css"`, `"js-top"` or `"js""`.

        :param assets:
            a path to file, a :ref:`webassets.Bundle <webassets:bundles>`
            instance or a callable that returns a
            :ref:`webassets.Bundle <webassets:bundles>` instance.

        :raises KeyError: if `type_` is not supported.