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
| Attribute | Type | Description |
|---|---|---|
| app_dirname | string = template_strings | The name of the subdirectory within installed applications where the engine looks for template source files. |
Constructor
Signature
def TemplateStrings(
params: dict
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| params | dict | A dictionary of configuration parameters for the template engine. |
Signature
def TemplateStrings(
params: dict
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| params | dict | A 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
| Name | Type | Description |
|---|---|---|
| template_code | string | The raw string content representing the template to be compiled. |
Returns
| Type | Description |
|---|---|
[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
| Name | Type | Description |
|---|---|---|
| template_name | string | The relative path or filename of the template to locate and load. |
Returns
| Type | Description |
|---|---|
[Template](../../base/template.md?sid=django_template_base_template) | A Template instance containing the content of the first matching file found. |