djblets.extensions.templatetags.djblets_extensions¶
- class ExtensionStaticMediaNodeMixin[source]¶
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.
- Parameters
- Returns
The HTML for loading the static media.
- Return type
- class ExtensionJavascriptNode(name)[source]¶
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.
- class ExtensionStylesheetNode(name)[source]¶
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.
- template_hook_point(context, name)[source]¶
Register a place where TemplateHooks can render to.
- Parameters
context (dict) – The template rendering context.
name (unicode) – The name of the CSS bundle to render.
- Returns
The rendered HTML.
- Return type
django.utils.safetext.SafeText
- ext_static(context, extension, path)[source]¶
Outputs 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
.
- ext_css_bundle(context, extension, name)[source]¶
Return HTML to import an extension’s CSS bundle.
- Parameters
context (dict) – The template rendering 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
django.utils.safetext.SafeText
- ext_js_bundle(context, extension, name)[source]¶
Return HTML to import an extension’s JavaScript bundle.
- Parameters
context (dict) – The template rendering 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
django.utils.safetext.SafeText
- load_extensions_css(context, extension_manager_key, default_bundles='default')[source]¶
Load all CSS bundles that can be rendered on the current page.
This will include all “default” bundles and any with an
apply_to
containing a URL name matching the current page.- Parameters
context (django.template.Context) – The template context.
extension_manager_key (unicode) – The key for the extension manager for these bundles.
default_bundles (unicode) – 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, extension_manager_key, default_bundles='default')[source]¶
Load all JavaScript bundles that can be rendered on the current page.
This will include all “default” bundles and any with an
apply_to
containing a URL name matching the current page.- Parameters
context (django.template.Context) – The template context.
extension_manager_key (unicode) – The key for the extension manager for these bundles.
default_bundles (unicode) – 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