Jump to >

djblets.extensions.templatetags.djblets_extensions

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.

Parameters:
  • *args (tuple) – Positional arguments to pass to the rendering function.
  • **kwargs (dict) – Keyword arguments to pass to the rendering function.
Returns:

The HTML for loading the static media.

Return type:

unicode

class ExtensionJavascriptNode(name)[source]

Bases: djblets.extensions.templatetags.djblets_extensions.ExtensionStaticMediaNodeMixin, pipeline.templatetags.pipeline.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.

class ExtensionStylesheetNode(name)[source]

Bases: djblets.extensions.templatetags.djblets_extensions.ExtensionStaticMediaNodeMixin, pipeline.templatetags.pipeline.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.

template_hook_point(context, name)[source]

Registers a place where TemplateHooks can render to.

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:
Returns:

The rendered HTML.

Return type:

django.utils.safetext.SafeString

ext_js_bundle(context, extension, name)[source]

Return HTML to import an extension’s JavaScript bundle.

Parameters:
Returns:

The rendered HTML.

Return type:

django.utils.safetext.SafeString

load_extensions_css(context, extension_manager_key, default_bundles=u'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:

unicode

load_extensions_js(context, extension_manager_key, default_bundles=u'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:

unicode

init_js_extensions(context, extension_manager_key)[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.