def _render_bundle(bundle_name):
    """
    Renders the HTML for a bundle in place - one HTML tag or many depending on settings.USE_BUNDLES
    """
    try:
        bundle = get_bundles()[bundle_name]
    except KeyError:
        raise ImproperlyConfigured("Bundle '%s' is not defined" % bundle_name)

    if bundle.use_bundle:
        return _render_file(bundle.bundle_type, bundle.get_url(), attrs=({'media':bundle.media} if bundle.media else {}))

    # Render files individually
    bundle_files = []

    for bundle_file in bundle.files:
        if bundle_file.precompile_in_debug:
            bundle_files.append(_render_file(bundle_file.bundle_type, bundle_file.precompile_url, attrs=({'media':bundle_file.media} if bundle.media else {})))
        else:
            bundle_files.append(_render_file(bundle_file.file_type, bundle_file.file_url, attrs=({'media':bundle_file.media} if bundle.media else {})))

    return '\n'.join(bundle_files)
Renders the HTML for a bundle in place - one HTML tag or many depending on settings.USE_BUNDLES