djblets.extensions.templatetags.djblets_extensions¶
Template tags for loading extension static media.
- class ExtensionStaticMediaNodeMixin[source]¶
- Bases: - object- Mixin for extension-specific static media rendering logic. - This is used to change the behavior for how static media in extensions are rendered, allowing us to work with both development setups and installed packages. - render_compressed(*args, **kwargs)[source]¶
- Render an extension media bundle to HTML. - If Pipeline is disabled (typically on development setups), this will attempt to render the compressed files, as normal. However, if that fails (due to the source files not being available in a package) or Pipeline is enabled (typically on a production setup), the bundle’s output file will be rendered instead. 
 
- class ExtensionJavascriptNode(name)[source]¶
- Bases: - ExtensionStaticMediaNodeMixin,- JavascriptNode- Template node for including extension-specific JavaScript. - This will allow both extensions in development mode or installed via a package to be used on a page. - __annotations__ = {}¶
 
- class ExtensionStylesheetNode(name)[source]¶
- Bases: - ExtensionStaticMediaNodeMixin,- StylesheetNode- Template node for including extension-specific CSS. - This will allow both extensions in development mode or installed via a package to be used on a page. - __annotations__ = {}¶
 
- template_hook_point(context: Union[Context, RequestContext], name: str) → SafeString[source]¶
- Register a place where TemplateHooks can render to. 
- ext_static(context: Context, extension: Extension, path: str) → str[source]¶
- Return the URL to the given static media file provided by an extension. - This works like the - {% static %}template tag, but takes an extension and generates a URL for the media file within the extension.- This is meant to be used with - djblets.extensions.staticfiles.ExtensionFinder.- Parameters:
- context ( - django.template.Context) – The current template context.
- extension ( - djblets.extensions.extension.Extension) – The extension that owns the static media file.
- path ( - str) – The relative path to the static media file.
 
- Returns:
- The resulting URL to the static media file. 
- Return type:
 
- ext_css_bundle(context: Context, extension: Extension, name: str) → SafeString[source]¶
- Return HTML to import an extension’s CSS bundle. - Parameters:
- context ( - django.template.Context) – The current template context.
- extension ( - djblets.extensions.extension.Extension) – The extension instance.
- name ( - str) – The name of the CSS bundle to render.
 
- Returns:
- The rendered HTML. 
- Return type:
 
- ext_js_bundle(context: Context, extension: Extension, name: str) → SafeString[source]¶
- Return HTML to import an extension’s JavaScript bundle. - Parameters:
- context ( - django.template.Context) – The current template context.
- extension ( - djblets.extensions.extension.Extension) – The extension instance.
- name ( - unicode) – The name of the CSS bundle to render.
 
- Returns:
- The rendered HTML. 
- Return type:
 
- load_extensions_css(context: Context, extension_manager_key: str, default_bundles: str = 'default') → SafeString[source]¶
- Load all CSS bundles that can be rendered on the current page. - This will include all “default” bundles and any with an - apply_tocontaining a URL name matching the current page.- Parameters:
- context ( - django.template.Context) – The template context.
- extension_manager_key ( - str) – The key for the extension manager for these bundles.
- default_bundles ( - str) – A string containing a comma-separated list of bundles to always include. Defaults to- "default".
 
- Returns:
- The HTML used to include the bundled content. 
- Return type:
 
- load_extensions_js(context: Context, extension_manager_key: str, default_bundles: str = 'default') → SafeString[source]¶
- Load all JavaScript bundles that can be rendered on the current page. - This will include all “default” bundles and any with an - apply_tocontaining a URL name matching the current page.- Parameters:
- context ( - django.template.Context) – The template context.
- extension_manager_key ( - str) – The key for the extension manager for these bundles.
- default_bundles ( - str) – A string containing a comma-separated list of bundles to always include. Defaults to- "default".
 
- Returns:
- The HTML used to include the bundled content. 
- Return type:
 
- init_js_extensions(context: Context, extension_manager_key: str) → dict[str, Any][source]¶
- Initializes all JavaScript extensions. - Each extension’s required JavaScript files will be loaded in the page, and their JavaScript-side Extension subclasses will be instantiated. - Parameters:
- context ( - django.template.Context) – The current template context.
- extension_manager_key ( - str) – The key for the extension manager for these bundles.
 
- Returns:
- Context variables to include for the - extensions/init_js_extensions.htmltemplate.
- Return type:
 
