API¶
function bareasgi_jinja2.add_jinja2 ¶
Summary¶
Adds jinja2 support ro bareASGI.
Description¶
This helper function can be used as follows:
app = Application()
env = jinja2.Environment(
loader=jinja2.FileSystemLoader('/path/to/templates')),
autoescape=jinja2.select_autoescape(['html', 'xml']),
enable_async=True
)
add_jinja2(app, env)
bareasgi_jinja2.add_jinja2(
app: Application,
env: jinja2.Environment,
info_key: Optional[str]
) -> AnyParameters¶
app: ApplicationThe bareASGI Application.
env: jinja2.EnvironmentThe jinja2 Environment
info_key: Optional[str] (optional)An optional key to overide the key in the supplied info dict where the jinja2 Environment is held. Defaults to None.
class Jinja2TemplateProvider ¶
Summary¶
The bareASGI Jinja2 template provider
bareasgi_jinja2.Jinja2TemplateProvider(
env: jinja2.Environment
) -> Noneasync class method Jinja2TemplateProvider.apply ¶
async Jinja2TemplateProvider.apply(
template_name: str,
variables: Mapping[strAny],
*,
status: int,
encoding: str,
info_key: str
) -> HttpResponseParameters¶
template_name: str variables: Mapping[strAny] status: int (optional) encoding: str (optional) info_key: str (optional)async method Jinja2TemplateProvider.render_string ¶
Summary¶
render a string from a template and variables.
async Jinja2TemplateProvider.render_string(
template_name: str,
variables: Mapping[str, Any]
) -> strParameters¶
template_name: strThe name of the template
variables: Mapping[str, Any]The variables to use