![]() |
Qucs-S S-parameter Viewer & RF Synthesis Tools
|

Public Member Functions | |
| None | __init_subclass__ (cls) |
| None | __init__ (self, Environment environment) |
| "te.Self" | bind (self, Environment environment) |
| str | preprocess (self, str source, t.Optional[str] name, t.Optional[str] filename=None) |
| t.Union["TokenStream", t.Iterable["Token"]] | filter_stream (self, "TokenStream" stream) |
| t.Union[nodes.Node, t.List[nodes.Node]] | parse (self, "Parser" parser) |
| nodes.ExtensionAttribute | attr (self, str name, t.Optional[int] lineno=None) |
| nodes.Call | call_method (self, str name, t.Optional[t.List[nodes.Expr]] args=None, t.Optional[t.List[nodes.Keyword]] kwargs=None, t.Optional[nodes.Expr] dyn_args=None, t.Optional[nodes.Expr] dyn_kwargs=None, t.Optional[int] lineno=None) |
Public Attributes | |
| identifier | |
| environment | |
Static Public Attributes | |
| t | identifier .ClassVar[str] |
| t | tags = set() |
| int | priority = 100 |
Extensions can be used to add extra functionality to the Jinja template system at the parser level. Custom extensions are bound to an environment but may not store environment specific data on `self`. The reason for this is that an extension can be bound to another environment (for overlays) by creating a copy and reassigning the `environment` attribute. As extensions are created by the environment they cannot accept any arguments for configuration. One may want to work around that by using a factory function, but that is not possible as extensions are identified by their import name. The correct way to configure the extension is storing the configuration values on the environment. Because this way the environment ends up acting as central configuration storage the attributes may clash which is why extensions have to ensure that the names they choose for configuration are not too generic. ``prefix`` for example is a terrible name, ``fragment_cache_prefix`` on the other hand is a good name as includes the name of the extension (fragment cache).
| nodes.ExtensionAttribute jinja2.ext.Extension.attr | ( | self, | |
| str | name, | ||
| t.Optional[int] | lineno = None |
||
| ) |
Return an attribute node for the current extension. This is useful
to pass constants on extensions to generated template code.
::
self.attr('_my_attribute', lineno=lineno)
| "te.Self" jinja2.ext.Extension.bind | ( | self, | |
| Environment | environment | ||
| ) |
Create a copy of this extension bound to another environment.
| nodes.Call jinja2.ext.Extension.call_method | ( | self, | |
| str | name, | ||
| t.Optional[t.List[nodes.Expr]] | args = None, |
||
| t.Optional[t.List[nodes.Keyword]] | kwargs = None, |
||
| t.Optional[nodes.Expr] | dyn_args = None, |
||
| t.Optional[nodes.Expr] | dyn_kwargs = None, |
||
| t.Optional[int] | lineno = None |
||
| ) |
Call a method of the extension. This is a shortcut for :meth:`attr` + :class:`jinja2.nodes.Call`.
| t.Union["TokenStream", t.Iterable["Token"]] jinja2.ext.Extension.filter_stream | ( | self, | |
| "TokenStream" | stream | ||
| ) |
It's passed a :class:`~jinja2.lexer.TokenStream` that can be used to filter tokens returned. This method has to return an iterable of :class:`~jinja2.lexer.Token`\\s, but it doesn't have to return a :class:`~jinja2.lexer.TokenStream`.
| t.Union[nodes.Node, t.List[nodes.Node]] jinja2.ext.Extension.parse | ( | self, | |
| "Parser" | parser | ||
| ) |
If any of the :attr:`tags` matched this method is called with the parser as first argument. The token the parser stream is pointing at is the name token that matched. This method has to return one or a list of multiple nodes.
Reimplemented in jinja2.ext.InternationalizationExtension, jinja2.ext.ExprStmtExtension, jinja2.ext.LoopControlExtension, and jinja2.ext.DebugExtension.
| str jinja2.ext.Extension.preprocess | ( | self, | |
| str | source, | ||
| t.Optional[str] | name, | ||
| t.Optional[str] | filename = None |
||
| ) |
This method is called before the actual lexing and can be used to preprocess the source. The `filename` is optional. The return value must be the preprocessed source.