jinja API reference
272 public APIs from jinja (pallets/jinja) — 100 classes, 55 functions, 117 methods. Signatures extracted by static analysis of the actual source.
Repository: pallets/jinja
| Kind | Count |
|---|---|
| Classes | 100 |
| Functions | 55 |
| Methods | 117 |
API list
class
src.jinja2.bccache.BucketBuckets are used to store the bytecode for one template.
method
src.jinja2.bccache.Bucket.bytecode_from_string(string:bytes) -> NoneLoad bytecode from bytes.
method
src.jinja2.bccache.Bucket.bytecode_to_string() -> bytesReturn the bytecode as bytes.
method
src.jinja2.bccache.Bucket.load_bytecode(f:t.BinaryIO) -> NoneLoads bytecode from a file or file like object.
method
src.jinja2.bccache.Bucket.reset() -> NoneResets the bucket (unloads the bytecode).
method
src.jinja2.bccache.Bucket.write_bytecode(f:t.IO[bytes]) -> NoneDump the bytecode into the file or file like object passed.
class
src.jinja2.bccache.FileSystemBytecodeCacheA bytecode cache that stores bytecode on the filesystem.
method
src.jinja2.compiler.CodeGenerator.blockvisit(nodes:t.Iterable[nodes.Node], frame:Frame) -> NoneVisit a list of nodes as block in a frame.
method
src.jinja2.compiler.CodeGenerator.buffer(frame:Frame) -> NoneEnable buffering for the frame from that point onwards.
method
src.jinja2.compiler.CodeGenerator.end_write(frame:Frame) -> NoneEnd the writing process started by `start_write`.
method
src.jinja2.compiler.CodeGenerator.fail(msg:str, lineno:int) -> 'te.NoReturn'Fail with a :exc:`TemplateAssertionError`.
method
src.jinja2.compiler.CodeGenerator.indent() -> NoneIndent by one.
method
src.jinja2.compiler.CodeGenerator.macro_body(node:nodes.Macro | nodes.CallBlock, frame:Frame) -> tuple[Frame, MacroRef]Dump the function def of a macro or call block.
method
src.jinja2.compiler.CodeGenerator.macro_def(macro_ref:MacroRef, frame:Frame) -> NoneDump the macro definition for the def created by macro_body.
method
src.jinja2.compiler.CodeGenerator.newline(node:nodes.Node | None=None, extra:int=0) -> NoneAdd one or more newlines before the next write.
method
src.jinja2.compiler.CodeGenerator.outdent(step:int=1) -> NoneOutdent by step.
method
src.jinja2.compiler.CodeGenerator.parameter_is_undeclared(target:str) -> boolChecks if a given target is an undeclared parameter.
method
src.jinja2.compiler.CodeGenerator.pop_parameter_definitions() -> NonePops the current parameter definitions set.
method
src.jinja2.compiler.CodeGenerator.position(node:nodes.Node) -> strReturn a human readable position for the node.
method
src.jinja2.compiler.CodeGenerator.push_assign_tracking() -> NonePushes a new layer for assignment tracking.
method
src.jinja2.compiler.CodeGenerator.return_buffer_contents(frame:Frame, force_unescaped:bool=False) -> NoneReturn the buffer contents of the frame.
method
src.jinja2.compiler.CodeGenerator.simple_write(s:str, frame:Frame, node:nodes.Node | None=None) -> NoneSimple shortcut for start_write + write + end_write.
method
src.jinja2.compiler.CodeGenerator.start_write(frame:Frame, node:nodes.Node | None=None) -> NoneYield or write into the frame buffer.
method
src.jinja2.compiler.CodeGenerator.temporary_identifier() -> strGet a new unique identifier.
method
src.jinja2.compiler.CodeGenerator.visit_Block(node:nodes.Block, frame:Frame) -> NoneCall a block and register it for the template.
method
src.jinja2.compiler.CodeGenerator.visit_Extends(node:nodes.Extends, frame:Frame) -> NoneCalls the extender.
method
src.jinja2.compiler.CodeGenerator.visit_FromImport(node:nodes.FromImport, frame:Frame) -> NoneVisit named imports.
method
src.jinja2.compiler.CodeGenerator.visit_Import(node:nodes.Import, frame:Frame) -> NoneVisit regular imports.
method
src.jinja2.compiler.CodeGenerator.visit_Include(node:nodes.Include, frame:Frame) -> NoneHandles includes.
method
src.jinja2.compiler.CodeGenerator.write(x:str) -> NoneWrite a string into the output stream.
method
src.jinja2.compiler.CodeGenerator.writeline(x:str, node:nodes.Node | None=None, extra:int=0) -> NoneCombination of newline and write.
class
src.jinja2.compiler.DependencyFinderVisitorA visitor that collects filter and test calls.
method
src.jinja2.compiler.DependencyFinderVisitor.visit_Block(node:nodes.Block) -> NoneStop visiting at blocks.
class
src.jinja2.compiler.FrameHolds compile time information for us.
method
src.jinja2.compiler.Frame.copy() -> 'te.Self'Create a copy of the current one.
method
src.jinja2.compiler.Frame.inner(isolated:bool=False) -> 'Frame'Return an inner frame.
method
src.jinja2.compiler.Frame.soft() -> 'te.Self'Return a soft frame.
class
src.jinja2.compiler.VisitorExitException used by the `UndeclaredNameVisitor` to signal a stop.
func
src.jinja2.compiler.find_undeclared(nodes:t.Iterable[nodes.Node], names:t.Iterable[str]) -> set[str]Check if the names passed are accessed undeclared.
func
src.jinja2.compiler.has_safe_repr(value:t.Any) -> boolDoes the node have a safe representation?
class
src.jinja2.environment.EnvironmentThe core component of Jinja is the `Environment`.
method
src.jinja2.environment.Environment.add_extension(extension:str | type['Extension']) -> NoneAdds an extension after the environment was created.
method
src.jinja2.environment.Environment.extend(**attributes:t.Any) -> NoneAdd the items to the instance of the environment if they do not exist yet.
method
src.jinja2.environment.Environment.getattr(obj:t.Any, attribute:str) -> t.AnyGet an item or attribute of an object but prefer the attribute.
method
src.jinja2.environment.Environment.getitem(obj:t.Any, argument:str | t.Any) -> t.Any | UndefinedGet an item or attribute of an object but prefer the item.
method
src.jinja2.environment.Environment.handle_exception(source:str | None=None) -> 'te.NoReturn'Exception handling helper.
method
src.jinja2.environment.Environment.iter_extensions() -> t.Iterator['Extension']Iterates over the extensions by priority.
method
src.jinja2.environment.Environment.join_path(template:str, parent:str) -> strJoin a template with the parent.
method
src.jinja2.environment.Environment.lexer() -> LexerThe lexer for this environment.
method
src.jinja2.environment.Environment.make_globals(d:t.MutableMapping[str, t.Any] | None) -> t.MutableMapping[str, t.Any]Make the globals map for a template.
method
src.jinja2.environment.Environment.parse(source:str, name:str | None=None, filename:str | None=None) -> nodes.TemplateParse the sourcecode and return the abstract syntax tree.
method
src.jinja2.environment.Environment.preprocess(source:str, name:str | None=None, filename:str | None=None) -> strPreprocesses the source with all extensions.
class
src.jinja2.environment.TemplateA compiled template that can be rendered.
method
src.jinja2.environment.Template.debug_info() -> list[tuple[int, int]]The debug info mapping.
method
src.jinja2.environment.Template.from_module_dict(environment:Environment, module_dict:t.MutableMapping[str, t.Any], globals:t.MutableMapping[str, t.Any]) -> 'Template'Creates a template object from a module.
method
src.jinja2.environment.Template.generate_async(*args:t.Any, **kwargs:t.Any) -> t.AsyncGenerator[str, object]An async version of :meth:`generate`.
method
src.jinja2.environment.Template.module() -> 'TemplateModule'The template as module.
method
src.jinja2.environment.Template.new_context(vars:dict[str, t.Any] | None=None, shared:bool=False, locals:t.Mapping[str, t.Any] | None=None) -> ContextCreate a new :class:`Context` for this template.
class
src.jinja2.environment.TemplateModuleRepresents an imported template.
func
src.jinja2.environment.create_cache(size:int) -> t.MutableMapping[tuple['weakref.ref[BaseLoader]', str], 'Template'] | NoneReturn the cache class for the given size.
func
src.jinja2.environment.get_spontaneous_environment(cls:type[_env_bound], *args:t.Any) -> _env_boundReturn a new spontaneous environment.
class
src.jinja2.exceptions.TemplateErrorBaseclass for all template errors.
class
src.jinja2.exceptions.TemplateNotFoundRaised if a template does not exist.
class
src.jinja2.exceptions.TemplateRuntimeErrorA generic runtime error in the template engine.
class
src.jinja2.exceptions.UndefinedErrorRaised if a template tries to operate on :class:`Undefined`.
method
src.jinja2.ext.Extension.attr(name:str, lineno:int | None=None) -> nodes.ExtensionAttributeReturn an attribute node for the current extension.
method
src.jinja2.ext.Extension.bind(environment:Environment) -> 'te.Self'Create a copy of this extension bound to another environment.
class
src.jinja2.ext.InternationalizationExtensionThis extension adds gettext support to Jinja.
method
src.jinja2.ext.InternationalizationExtension.parse(parser:'Parser') -> nodes.Node | list[nodes.Node]Parse a translatable tag.
class
src.jinja2.ext.LoopControlExtensionAdds break and continue to the template engine.
func
src.jinja2.filters.do_attr(environment:'Environment', obj:t.Any, name:str) -> Undefined | t.AnyGet an attribute of an object.
func
src.jinja2.filters.do_batch(value:'t.Iterable[V]', linecount:int, fill_with:'V | None'=None) -> 't.Iterator[list[V]]'A filter that batches items.
func
src.jinja2.filters.do_capitalize(s:str) -> strCapitalize a value.
func
src.jinja2.filters.do_center(value:str, width:int=80) -> strCenters the value in a field of a given width.
func
src.jinja2.filters.do_dictsort(value:t.Mapping[K, V], case_sensitive:bool=False, by:'te.Literal["key", "value"]'='key', reverse:bool=False) -> list[tuple[K, V]]Sort a dict and yield (key, value) pairs.
func
src.jinja2.filters.do_filesizeformat(value:str | float | int, binary:bool=False) -> strFormat the value like a 'human-readable' file size (i.e.
func
src.jinja2.filters.do_float(value:t.Any, default:float=0.0) -> floatConvert the value into a floating point number.
func
src.jinja2.filters.do_forceescape(value:'str | HasHTML') -> MarkupEnforce HTML escaping.
func
src.jinja2.filters.do_int(value:t.Any, default:int=0, base:int=10) -> intConvert the value into an integer.
func
src.jinja2.filters.do_last(environment:'Environment', seq:'t.Reversible[V]') -> 'V | Undefined'Return the last item of a sequence.
func
src.jinja2.filters.do_lower(s:str) -> strConvert a value to lowercase.
func
src.jinja2.filters.do_mark_unsafe(value:str) -> strMark a value as unsafe.
func
src.jinja2.filters.do_max(environment:'Environment', value:'t.Iterable[V]', case_sensitive:bool=False, attribute:str | int | None=None) -> 'V | Undefined'Return the largest item from the sequence.
func
src.jinja2.filters.do_min(environment:'Environment', value:'t.Iterable[V]', case_sensitive:bool=False, attribute:str | int | None=None) -> 'V | Undefined'Return the smallest item from the sequence.
func
src.jinja2.filters.do_pprint(value:t.Any) -> strPretty print a variable.
func
src.jinja2.filters.do_random(context:'Context', seq:'t.Sequence[V]') -> 'V | Undefined'Return a random item from the sequence.
func
src.jinja2.filters.do_round(value:float, precision:int=0, method:'te.Literal["common", "ceil", "floor"]'='common') -> floatRound the number to a given precision.
func
src.jinja2.filters.do_striptags(value:'str | HasHTML') -> strStrip SGML/XML tags and replace adjacent whitespace by one space.
func
src.jinja2.filters.do_title(s:str) -> strReturn a titlecased version of the value.
func
src.jinja2.filters.do_trim(value:str, chars:str | None=None) -> strStrip leading and trailing characters, by default whitespace.
func
src.jinja2.filters.do_truncate(env:'Environment', s:str, length:int=255, killwords:bool=False, end:str='...', leeway:int | None=None) -> strReturn a truncated copy of the string.
func
src.jinja2.filters.do_upper(s:str) -> strConvert a value to uppercase.
func
src.jinja2.filters.do_urlencode(value:str | t.Mapping[str, t.Any] | t.Iterable[tuple[str, t.Any]]) -> strQuote data for use in a URL path or query using UTF-8.
func
src.jinja2.filters.do_wordcount(s:str) -> intCount the words in that string.
func
src.jinja2.filters.do_wordwrap(environment:'Environment', s:str, width:int=79, break_long_words:bool=True, wrapstring:str | None=None, break_on_hyphens:bool=True) -> strWrap a string to the given width.
func
src.jinja2.filters.ignore_case(value:V) -> VFor use as a postprocessor for :func:`make_attrgetter`.
func
src.jinja2.filters.sync_do_first(environment:'Environment', seq:'t.Iterable[V]') -> 'V | Undefined'Return the first item of a sequence.
func
src.jinja2.filters.sync_do_list(value:'t.Iterable[V]') -> 'list[V]'Convert the value into a list.
class
src.jinja2.idtracking.FrameSymbolVisitorA visitor for `Frame.inspect`.
method
src.jinja2.idtracking.FrameSymbolVisitor.visit_Assign(node:nodes.Assign, **kwargs:t.Any) -> NoneVisit assignments in the correct order.
method
src.jinja2.idtracking.FrameSymbolVisitor.visit_AssignBlock(node:nodes.AssignBlock, **kwargs:t.Any) -> NoneStop visiting at block assigns.
method
src.jinja2.idtracking.FrameSymbolVisitor.visit_Block(node:nodes.Block, **kwargs:t.Any) -> NoneStop visiting at blocks.
method
src.jinja2.idtracking.FrameSymbolVisitor.visit_For(node:nodes.For, **kwargs:t.Any) -> NoneVisiting stops at for blocks.
method
src.jinja2.idtracking.FrameSymbolVisitor.visit_Name(node:nodes.Name, store_as_param:bool=False, **kwargs:t.Any) -> NoneAll assignments to names go through this function.
method
src.jinja2.idtracking.FrameSymbolVisitor.visit_OverlayScope(node:nodes.OverlayScope, **kwargs:t.Any) -> NoneDo not visit into overlay scopes.
method
src.jinja2.idtracking.FrameSymbolVisitor.visit_Scope(node:nodes.Scope, **kwargs:t.Any) -> NoneStop visiting at scopes.
class
src.jinja2.lexer.FailureClass that raises a `TemplateSyntaxError` if called.
class
src.jinja2.lexer.LexerClass that implements a lexer for a given environment.
method
src.jinja2.lexer.Token.test(expr:str) -> boolTest a token against a token expression.
class
src.jinja2.lexer.TokenStreamA token stream is an iterable that yields :class:`Token`\s.
method
src.jinja2.lexer.TokenStream.close() -> NoneClose the stream.
method
src.jinja2.lexer.TokenStream.eos() -> boolAre we at the end of the stream?
method
src.jinja2.lexer.TokenStream.expect(expr:str) -> TokenExpect a given token type and return it.
method
src.jinja2.lexer.TokenStream.look() -> TokenLook at the next token.
method
src.jinja2.lexer.TokenStream.next_if(expr:str) -> Token | NonePerform the token test and return the token if it matched.
method
src.jinja2.lexer.TokenStream.push(token:Token) -> NonePush a token back to the stream.
method
src.jinja2.lexer.TokenStream.skip(n:int=1) -> NoneGot n tokens ahead.
method
src.jinja2.lexer.TokenStream.skip_if(expr:str) -> boolLike :meth:`next_if` but only returns `True` or `False`.
class
src.jinja2.lexer.TokenStreamIteratorThe iterator for tokenstreams.
func
src.jinja2.lexer.compile_rules(environment:'Environment') -> list[tuple[str, str]]Compiles all the rules from the environment into a list of rules.
func
src.jinja2.lexer.count_newlines(value:str) -> intCount the number of newline characters in the string.
func
src.jinja2.lexer.describe_token(token:'Token') -> strReturns a description of the token.
func
src.jinja2.lexer.describe_token_expr(expr:str) -> strLike `describe_token` but for token expressions.
func
src.jinja2.lexer.get_lexer(environment:'Environment') -> 'Lexer'Return a lexer which is probably cached.
class
src.jinja2.loaders.BaseLoaderBaseclass for all loaders.
method
src.jinja2.loaders.BaseLoader.list_templates() -> list[str]Iterates over all templates.
method
src.jinja2.loaders.BaseLoader.load(environment:'Environment', name:str, globals:t.MutableMapping[str, t.Any] | None=None) -> 'Template'Loads a template.
class
src.jinja2.loaders.FileSystemLoaderLoad templates from a directory in the file system.
class
src.jinja2.loaders.FunctionLoaderA loader that is passed a function which does the loading.
class
src.jinja2.loaders.ModuleLoaderThis loader loads templates from precompiled templates.
class
src.jinja2.loaders.PackageLoaderLoad templates from a directory in a Python package.
func
src.jinja2.loaders.split_template_path(template:str) -> list[str]Split a path into segments and perform a sanity check.
class
src.jinja2.meta.TrackingCodeGeneratorWe abuse the code generator for introspection.
method
src.jinja2.meta.TrackingCodeGenerator.enter_frame(frame:Frame) -> NoneRemember all undeclared identifiers.
method
src.jinja2.meta.TrackingCodeGenerator.write(x:str) -> NoneDon't write.
func
src.jinja2.meta.find_referenced_templates(ast:nodes.Template) -> t.Iterator[str | None]Finds all the referenced templates from the AST.
func
src.jinja2.nativetypes.native_concat(values:t.Iterable[t.Any]) -> t.Any | NoneReturn a native Python type from the list of compiled nodes.
class
src.jinja2.nodes.AddAdd the left to the right node.
class
src.jinja2.nodes.AndShort circuited AND.
class
src.jinja2.nodes.AssignAssigns an expression to a target.
class
src.jinja2.nodes.AssignBlockAssigns a block to a target.
class
src.jinja2.nodes.BinExprBaseclass for all binary expressions.
class
src.jinja2.nodes.BlockA node that represents a block.
class
src.jinja2.nodes.BreakBreak a loop.
class
src.jinja2.nodes.CallCalls an expression.
class
src.jinja2.nodes.CallBlockLike a macro without a name but a call instead.
class
src.jinja2.nodes.CompareCompares an expression with some other expressions.
class
src.jinja2.nodes.CondExprA conditional expression (inline if expression).
class
src.jinja2.nodes.ConstAll constant values.
class
src.jinja2.nodes.ContextReferenceReturns the current template context.
class
src.jinja2.nodes.ContinueContinue a loop.
class
src.jinja2.nodes.DerivedContextReferenceReturn the current template context including locals.
class
src.jinja2.nodes.DictAny dict literal such as ``{1: 2, 3: 4}``.
class
src.jinja2.nodes.DivDivides the left by the right node.
class
src.jinja2.nodes.EnvironmentAttributeLoads an attribute from the environment object.
class
src.jinja2.nodes.EvalContextHolds evaluation time information.
class
src.jinja2.nodes.EvalContextModifierModifies the eval context.
class
src.jinja2.nodes.ExprBaseclass for all expressions.
method
src.jinja2.nodes.Expr.can_assign() -> boolCheck if it's possible to assign something to this node.
class
src.jinja2.nodes.ExprStmtA statement that evaluates an expression and discards the result.
class
src.jinja2.nodes.ExtendsRepresents an extends statement.
class
src.jinja2.nodes.ExtensionAttributeReturns the attribute of an extension bound to the environment.
class
src.jinja2.nodes.FilterApply a filter to an expression.
class
src.jinja2.nodes.FilterBlockNode for filter sections.
class
src.jinja2.nodes.ForThe for loop.
class
src.jinja2.nodes.FromImportA node that represents the from import tag.
class
src.jinja2.nodes.GetitemGet an attribute or item from an expression and prefer the item.
class
src.jinja2.nodes.HelperNodes that exist in a specific context only.
class
src.jinja2.nodes.IfIf `test` is true, `body` is rendered, else `else_`.
class
src.jinja2.nodes.ImportA node that represents the import tag.
class
src.jinja2.nodes.ImpossibleRaised if the node could not perform a requested action.
class
src.jinja2.nodes.IncludeA node that represents the include tag.
class
src.jinja2.nodes.InternalNameAn internal name in the compiler.
class
src.jinja2.nodes.KeywordA key, value pair for keyword arguments where key is a string.
class
src.jinja2.nodes.ListAny list literal such as ``[1, 2, 3]``
class
src.jinja2.nodes.LiteralBaseclass for literals.
class
src.jinja2.nodes.MacroA macro definition.
class
src.jinja2.nodes.MarkSafeMark the wrapped expression as safe (wrap it as `Markup`).
class
src.jinja2.nodes.ModLeft modulo right.
class
src.jinja2.nodes.MulMultiplies the left with the right node.
class
src.jinja2.nodes.NSRefReference to a namespace value assignment
class
src.jinja2.nodes.NameLooks up a name or stores a value in a name.
class
src.jinja2.nodes.NegMake the expression negative.
class
src.jinja2.nodes.NodeBaseclass for all Jinja nodes.
method
src.jinja2.nodes.Node.find(node_type:type[_NodeBound]) -> _NodeBound | NoneFind the first node of a given type.
method
src.jinja2.nodes.Node.find_all(node_type:type[_NodeBound] | tuple[type[_NodeBound], ...]) -> t.Iterator[_NodeBound]Find all the nodes of a given type.
method
src.jinja2.nodes.Node.iter_child_nodes(exclude:t.Container[str] | None=None, only:t.Container[str] | None=None) -> t.Iterator['Node']Iterates over all direct child nodes of the node.
method
src.jinja2.nodes.Node.set_ctx(ctx:str) -> 'Node'Reset the context of a node and all child nodes.
method
src.jinja2.nodes.Node.set_environment(environment:'Environment') -> 'Node'Set the environment for all nodes.
method
src.jinja2.nodes.Node.set_lineno(lineno:int, override:bool=False) -> 'Node'Set the line numbers of the node and children.
class
src.jinja2.nodes.NotNegate the expression.
class
src.jinja2.nodes.OperandHolds an operator and an expression.
class
src.jinja2.nodes.OrShort circuited OR.
class
src.jinja2.nodes.OutputA node that holds multiple expressions which are then printed out.
class
src.jinja2.nodes.OverlayScopeAn overlay scope for extensions.
class
src.jinja2.nodes.PairA key, value pair for dicts.
class
src.jinja2.nodes.PosMake the expression positive (noop for most expressions)
class
src.jinja2.nodes.PowLeft to the power of right.
class
src.jinja2.nodes.ScopeAn artificial scope.
class
src.jinja2.nodes.ScopedEvalContextModifierModifies the eval context and reverts it later.
class
src.jinja2.nodes.SliceRepresents a slice object.
class
src.jinja2.nodes.StmtBase node for all statements.
class
src.jinja2.nodes.SubSubtract the right from the left node.
class
src.jinja2.nodes.TemplateNode that represents a template.
class
src.jinja2.nodes.TemplateDataA constant template string.
class
src.jinja2.nodes.TestApply a test to an expression.
class
src.jinja2.nodes.UnaryExprBaseclass for all unary expressions.
class
src.jinja2.nodes.WithSpecific node for with statements.
class
src.jinja2.parser.ParserThis is the central parsing class Jinja uses.
method
src.jinja2.parser.Parser.fail_eof(end_tokens:tuple[str, ...] | None=None, lineno:int | None=None) -> 'te.NoReturn'Like fail_unknown_tag but for end of template situations.
method
src.jinja2.parser.Parser.fail_unknown_tag(name:str, lineno:int | None=None) -> 'te.NoReturn'Called if the parser encounters an unknown tag.
method
src.jinja2.parser.Parser.is_tuple_end(extra_end_rules:tuple[str, ...] | None=None) -> boolAre we at the end of a tuple?
method
src.jinja2.parser.Parser.parse() -> nodes.TemplateParse the whole template into a `Template` node.
method
src.jinja2.parser.Parser.parse_expression(with_condexpr:bool=True) -> nodes.ExprParse an expression.
method
src.jinja2.parser.Parser.parse_for() -> nodes.ForParse a for loop.
method
src.jinja2.parser.Parser.parse_if() -> nodes.IfParse an if construct.
method
src.jinja2.parser.Parser.parse_primary(with_namespace:bool=False) -> nodes.ExprParse a name or literal value.
method
src.jinja2.parser.Parser.parse_set() -> nodes.Assign | nodes.AssignBlockParse an assign statement.
method
src.jinja2.parser.Parser.parse_statement() -> nodes.Node | list[nodes.Node]Parse a single statement.
class
src.jinja2.runtime.BlockReferenceOne block on a template reference.
method
src.jinja2.runtime.BlockReference.super() -> t.Union['BlockReference', 'Undefined']Super the block.
class
src.jinja2.runtime.ContextThe template context holds the variables of a template.
method
src.jinja2.runtime.Context.derived(locals:dict[str, t.Any] | None=None) -> 'Context'Internal helper function to create a derived context.
method
src.jinja2.runtime.Context.get_exported() -> dict[str, t.Any]Get a new dict with the exported variables.
method
src.jinja2.runtime.Context.super(name:str, current:t.Callable[['Context'], t.Iterator[str]]) -> t.Union['BlockReference', 'Undefined']Render a parent block.
class
src.jinja2.runtime.DebugUndefinedAn undefined that returns the debug info when printed.
method
src.jinja2.runtime.LoopContext.first() -> boolWhether this is the first iteration of the loop.
method
src.jinja2.runtime.LoopContext.index() -> intCurrent iteration of the loop, starting at 1.
method
src.jinja2.runtime.LoopContext.last() -> boolWhether this is the last iteration of the loop.
method
src.jinja2.runtime.LoopContext.length() -> intLength of the iterable.
method
src.jinja2.runtime.LoopContext.nextitem() -> t.Union[t.Any, 'Undefined']The item in the next iteration.
method
src.jinja2.runtime.LoopContext.previtem() -> t.Union[t.Any, 'Undefined']The item in the previous iteration.
method
src.jinja2.runtime.LoopContext.revindex() -> intNumber of iterations from the end of the loop, ending at 1.
method
src.jinja2.runtime.LoopContext.revindex0() -> intNumber of iterations from the end of the loop, ending at 0.
class
src.jinja2.runtime.MacroWraps a macro function.
class
src.jinja2.runtime.TemplateReferenceThe `self` in templates.
class
src.jinja2.runtime.UndefinedThe default undefined type.
func
src.jinja2.runtime.identity(x:V) -> VReturns its argument.
func
src.jinja2.runtime.markup_join(seq:t.Iterable[t.Any]) -> strConcatenation that escapes if necessary and converts to string.
func
src.jinja2.runtime.str_join(seq:t.Iterable[t.Any]) -> strSimple args to string conversion and concatenation.
class
src.jinja2.sandbox.SandboxedEnvironmentThe sandboxed environment.
method
src.jinja2.sandbox.SandboxedEnvironment.call(__context:Context, __obj:t.Any, *args:t.Any, **kwargs:t.Any) -> t.AnyCall an object from sandboxed code.
method
src.jinja2.sandbox.SandboxedEnvironment.getattr(obj:t.Any, attribute:str) -> t.Any | UndefinedSubscribe an object from sandboxed code and prefer the attribute.
method
src.jinja2.sandbox.SandboxedEnvironment.getitem(obj:t.Any, argument:str | t.Any) -> t.Any | UndefinedSubscribe an object from sandboxed code.
method
src.jinja2.sandbox.SandboxedEnvironment.is_safe_callable(obj:t.Any) -> boolCheck if an object is safely callable.
method
src.jinja2.sandbox.SandboxedEnvironment.unsafe_undefined(obj:t.Any, attribute:str) -> UndefinedReturn an undefined object for unsafe attributes.
func
src.jinja2.sandbox.is_internal_attribute(obj:t.Any, attr:str) -> boolTest if the attribute given is an internal python attribute.
func
src.jinja2.sandbox.unsafe(f:F) -> FMarks a function or method as unsafe.
method
src.jinja2.utils.Cycler.current() -> t.AnyReturn the current item.
method
src.jinja2.utils.Cycler.next() -> t.AnyReturn the current item, then advance :attr:`current` to the next item.
method
src.jinja2.utils.Cycler.reset() -> NoneResets the current item to the first item.
class
src.jinja2.utils.JoinerA joining helper for templates.
class
src.jinja2.utils.LRUCacheA simple LRU Cache implementation.
method
src.jinja2.utils.LRUCache.clear() -> NoneClear the cache.
method
src.jinja2.utils.LRUCache.copy() -> 'te.Self'Return a shallow copy of the instance.
method
src.jinja2.utils.LRUCache.get(key:t.Any, default:t.Any=None) -> t.AnyReturn an item from the cache dict or `default`
method
src.jinja2.utils.LRUCache.items() -> t.Iterable[tuple[t.Any, t.Any]]Return a list of items.
method
src.jinja2.utils.LRUCache.keys() -> t.Iterable[t.Any]Return a list of all keys ordered by most recent usage.
method
src.jinja2.utils.LRUCache.values() -> t.Iterable[t.Any]Return a list of all values.
class
src.jinja2.utils.NamespaceA namespace object that can hold arbitrary attributes.
func
src.jinja2.utils.clear_caches() -> NoneJinja keeps internal caches for environments and lexers.
func
src.jinja2.utils.consume(iterable:t.Iterable[t.Any]) -> NoneConsumes an iterable without doing anything with it.
func
src.jinja2.utils.generate_lorem_ipsum(n:int=5, html:bool=True, min:int=20, max:int=100) -> strGenerate some lorem ipsum for the template.
func
src.jinja2.utils.import_string(import_name:str, silent:bool=False) -> t.AnyImports an object based on a string.
func
src.jinja2.utils.internalcode(f:F) -> FMarks the function as internally used
func
src.jinja2.utils.is_undefined(obj:t.Any) -> boolCheck if the object passed is undefined.
func
src.jinja2.utils.object_type_repr(obj:t.Any) -> strReturns the name of the object's type.
func
src.jinja2.utils.pformat(obj:t.Any) -> strFormat an object using :func:`pprint.pformat`.
func
src.jinja2.utils.url_quote(obj:t.Any, charset:str='utf-8', for_qs:bool=False) -> strQuote a string for use in a URL using the given charset.
func
src.jinja2.utils.urlize(text:str, trim_url_limit:int | None=None, rel:str | None=None, target:str | None=None, extra_schemes:t.Iterable[str] | None=None) -> strConvert URLs in text into clickable links.
method
src.jinja2.visitor.NodeVisitor.generic_visit(node:Node, *args:t.Any, **kwargs:t.Any) -> t.AnyCalled if no explicit visitor function exists for a node.
method
src.jinja2.visitor.NodeVisitor.visit(node:Node, *args:t.Any, **kwargs:t.Any) -> t.AnyVisit a node.
About this data
These signatures were extracted from the public source of pallets/jinja
using Python's ast module. Argument names, default values,
type annotations and return types are taken verbatim from the code.
Implementation bodies are never stored. See
how it works for details.