Skip to main content

TemplateStrings

This class provides a template engine backend that processes raw strings using a basic template system. It enables loading templates directly from string input or by locating and reading files from the file system based on configured directory paths. The class inherits from a base engine interface to ensure compatibility with standard template loading and rendering workflows.

Attributes

AttributeTypeDescription
app_dirnamestring = template_stringsThe name of the subdirectory within installed applications where the engine looks for template source files.

Constructor

Signature

def TemplateStrings(
params: dict
) - > null

Parameters

NameTypeDescription
paramsdictA dictionary of configuration parameters for the template engine.

Signature

def TemplateStrings(
params: dict
) - > null

Parameters

NameTypeDescription
paramsdictA dictionary of configuration settings including engine options and directory paths.

Methods


from_string()

@classmethod
def from_string(
template_code: string
) - > [Template](../../base/template.md?sid=django_template_base_template)

Creates a Template object directly from the provided raw template source code string.

Parameters

NameTypeDescription
template_codestringThe raw string content representing the template to be compiled.

Returns

TypeDescription
[Template](../../base/template.md?sid=django_template_base_template)A Template instance initialized with the provided source code.

get_template()

@classmethod
def get_template(
template_name: string
) - > [Template](../../base/template.md?sid=django_template_base_template)

Loads a template by searching through configured template directories for a file matching the specified name.

Parameters

NameTypeDescription
template_namestringThe relative path or filename of the template to locate and load.

Returns

TypeDescription
[Template](../../base/template.md?sid=django_template_base_template)A Template instance containing the content of the first matching file found.