Add iptable-parser as submodule

This commit is contained in:
infidel
2023-10-30 14:40:43 +07:00
parent 64c9e9c11b
commit be27c0882e
35887 changed files with 2661509 additions and 69 deletions

View File

@@ -0,0 +1,26 @@
"""
Wrapper for loading templates from a plain Python dict.
"""
from django.template import Origin, TemplateDoesNotExist
from .base import Loader as BaseLoader
class Loader(BaseLoader):
def __init__(self, engine, templates_dict):
self.templates_dict = templates_dict
super().__init__(engine)
def get_contents(self, origin):
try:
return self.templates_dict[origin.name]
except KeyError:
raise TemplateDoesNotExist(origin)
def get_template_sources(self, template_name):
yield Origin(
name=template_name,
template_name=template_name,
loader=self,
)