Skip to main content

Literal

A basic self-resolvable object similar to a Django template variable.

Attributes

AttributeTypeDescription
idstring = "literal"Internal identifier used by the parser to categorize the token type.
lbpinteger = 0Left binding power used by the Pratt parser to determine operator precedence.

Constructor

Signature

def Literal(
value: any
) - > null

Parameters

NameTypeDescription
valueanyThe value to be stored and managed by the Literal object.

Signature

def Literal(
value: any
) - > null

Parameters

NameTypeDescription
valueanyThe 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

TypeDescription
stringThe 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

NameTypeDescription
parser[Parser](../../test/html/parser.md?sid=django_test_html_parser)The parser instance currently processing the token stream

Returns

TypeDescription
[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

NameTypeDescription
contextdictThe template context containing variables and filters used for resolution

Returns

TypeDescription
anyThe original value passed during initialization