Literal
A basic self-resolvable object similar to a Django template variable.
Attributes
| Attribute | Type | Description |
|---|---|---|
| id | string = "literal" | Internal identifier used by the parser to categorize the token type. |
| lbp | integer = 0 | Left binding power used by the Pratt parser to determine operator precedence. |
Constructor
Signature
def Literal(
value: any
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| value | any | The value to be stored and managed by the Literal object. |
Signature
def Literal(
value: any
) - > null
Parameters
| Name | Type | Description |
|---|---|---|
| value | any | The raw value to be stored and later returned during evaluation |
Methods
display()
@classmethod
def display() - > string
Returns a string representation of the internal value using the built-in repr() function.
Returns
| Type | Description |
|---|---|
string | The formal string representation of the literal's value |
nud()
@classmethod
def nud(
parser: [Parser](../../test/html/parser.md?sid=django_test_html_parser)
) - > [Literal](literal.md?sid=django_template_smartif_literal)
Returns the token itself during the null denotation phase of parsing.
Parameters
| Name | Type | Description |
|---|---|---|
| parser | [Parser](../../test/html/parser.md?sid=django_test_html_parser) | The parser instance currently processing the token stream |
Returns
| Type | Description |
|---|---|
[Literal](literal.md?sid=django_template_smartif_literal) | The current Literal instance |
eval()
@classmethod
def eval(
context: dict
) - > any
Resolves the literal to its underlying value within a given context.
Parameters
| Name | Type | Description |
|---|---|---|
| context | dict | The template context containing variables and filters used for resolution |
Returns
| Type | Description |
|---|---|
any | The original value passed during initialization |