#27130: Allow using the DjangoTemplates engine without configuring settings
-------------------------------------+-------------------------------------
Reporter: Al Johri | Owner: reficul31
Type: | Status: assigned
Cleanup/optimization |
Component: Template system | Version: master
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Aymeric Augustin):
In fact using `django.template.Engine` in standalone mode already works:
{{{
>>> from django.template import Context, Engine
>>> engine = Engine()
>>> template = engine.from_string("Hello {{ name }}!")
>>> context = Context({'name': "world"})
>>> template.render(context)
'Hello world!'
}}}
`DjangoTemplates` is a thin integration layer for configuring an `Engine`
according to the project settings. It doesn't make sense to remove its
dependencies on settings. Just use `Engine` directly.
The documentation explains the roles of these classes without ambiguity
and specifically mentions using the template engine outside of a Django
project (meaning without Django settings):
https://docs.djangoproject.com/en/1.10/topics/templates/#engine
> django.template.Engine encapsulates an instance of the Django template
system. The main reason for instantiating an Engine directly is to use the
Django template language outside of a Django project.
> django.template.backends.django.DjangoTemplates is a thin wrapper
adapting django.template.Engine to Django’s template backend API.
For these reasons, I don't see what needs to be done here.
https://docs.djangoproject.com/en/1.10/topics/templates/#components
`DjangoTemplates`
--
Ticket URL: <https://code.djangoproject.com/ticket/27130#comment:13>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/065.bb5fb1755b503e3a128109263ac9de90%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.