General housekeeping update.
- Bump version to 0.6.0 - Add template functions to merge dictionaries for loading JSON data inside them - Add extension management separate from MIME type - Make the `tembed` processor which runs a generic jinja template through embedding in the template
This commit is contained in:
@ -28,5 +28,4 @@ class Jinja2(PassThrough):
|
||||
tmpl = template_env.from_string("".join([x for x in input_file]))
|
||||
return tmpl.render(metadata=ctx)
|
||||
|
||||
|
||||
processor = Jinja2
|
||||
|
@ -24,8 +24,7 @@ class Jinja2PageEmbed(Processor):
|
||||
str: the new name for the file
|
||||
|
||||
"""
|
||||
|
||||
return os.path.splitext(oldname)[0] + ".html"
|
||||
return os.path.splitext(oldname)[0] + "." + self.extension(oldname, ctx)
|
||||
|
||||
def mime_type(self, oldname: str, ctx: Optional[Dict] = None) -> str:
|
||||
"""Return the mimetype of the post-processed file.
|
||||
@ -38,7 +37,7 @@ class Jinja2PageEmbed(Processor):
|
||||
str: the new mimetype of the file after processing
|
||||
|
||||
"""
|
||||
return "text/html"
|
||||
return ctx.get("mime", "text/html")
|
||||
|
||||
def process(self, input_file: Iterable, ctx: Optional[Dict] = None) -> Iterable:
|
||||
"""Return an iterable object of the post-processed file.
|
||||
@ -69,7 +68,7 @@ class Jinja2PageEmbed(Processor):
|
||||
str: the new extension of the file after processing
|
||||
|
||||
"""
|
||||
return "html"
|
||||
return ctx.get("extension", "html")
|
||||
|
||||
|
||||
processor = Jinja2PageEmbed
|
||||
|
@ -64,3 +64,6 @@ class Processor(abc.ABC): # pragma: no cover
|
||||
Returns:
|
||||
iterable: The post-processed output stream
|
||||
"""
|
||||
|
||||
def repr(self) -> str:
|
||||
return self.__class__.__name__
|
||||
|
Reference in New Issue
Block a user