futurefinity.template – FutureFinity Template Wrapper

class futurefinity.template.TemplateLoader(template_path: typing.Union, cache_template: bool=True)[source]

The TemplateLoader.

The Default template loader of FutureFinity.

find_abs_path(template_name: str) → str[source]

Find the absolute path of the template from the template_path.

If no matched file found, it will raise a FileNotFoundError.

load_template(template_name: str) → 'Template'[source]

Load and parse the template.

load_template_file_content(file_path)[source]

Load a file synchronously. This function can be put into a thread executor to load the file content concurrently.

futurefinity.template.render_template(template_name: str)[source]

Decorator to render template gracefully.

Only effective when nothing is written.

Example:

@render_template("index.htm")
async def get(self, *args, **kwargs):
    return {'content': 'Hello, World!!'}