Jinja2 Simple Tags

screenshot of Jinja2 Simple Tags
django

Base classes for quick-and-easy template tag development

Overview

jinja2-simple-tags is a library that provides a simple way to create custom templatetags in Jinja2 templates. It is compatible with Python versions 3.6 and above, as well Jinja2 version 2.10 and above.

Features

  • StandaloneTag: A tag that doesn't require a closing tag. It can be used to create custom tags in Jinja2 templates.
  • Escaping: The output of StandaloneTag is escaped by default, but can be disabled by setting the safe_output property to True. You can also explicitly mark the output as safe by returning a jinja2.Markup object from the render() method.
  • ContainerTag: A tag that requires a closing tag and can contain arbitrary content. It can be used to create custom tags in Jinja2 templates.
  • Context: The current context can be accessed using the self.context attribute of the tag class.
  • Assignment: Both ContainerTag and StandaloneTag support assigning the output to a variable in the context using the as keyword.

Summary

jinja2-simple-tags is a library that simplifies the creation of custom templatetags in Jinja2 templates. It provides two tag types, StandaloneTag and ContainerTag, which can be used to create custom tags that either require or don't require a closing tag. The library also supports context access and assignment of tag output to variables.

django
Django

Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. It follows the model-view-controller (MVC) architectural pattern, providing an extensive set of built-in tools and conventions to streamline the creation of robust and scalable web applications.