liquid.tags.manager
module
liquid.tags.manager
Provide tag manager
Classes
TagManager
— A manager for tags</>
Functions
decode_raw
(
body
)
(str) — Decode the encoded string in body</>
function
liquid.tags.manager.
decode_raw
(
body
)
Decode the encoded string in body
The start string in body is encoded so that they won't be recognized as variable/comment/block by jinja. This way, we can protect the body from being tokenized.
Parameters
body
(str) — The body
Returns (str)
The decoded string.
class
liquid.tags.manager.
TagManager
(
)
A manager for tags
Attributes
envs
(dict(str: bool)) — a mapping of tag names and whether environment should be passedto the parser functionsnames
(set of str) — Get a set of the tag names</>names_raw
(set of str) — Get a set of names of tags whose body will be kept raw</>raws
(dict(str: bool)) — a mapping of tag names and whether the tag body should bekept raw.tags
(dict(str: )) — a mapping of tag names and parser functions
method
register
(
name_or_tagparser=None
, env=False
, raw=False
)
Register a filter
This can be used as a decorator
Examples
>>> @tag_manager.register>>> def comment(token, parser):
>>> from jinja2 import nodes
>>> return nodes.Const("")
Parameters
name_or_tagparser
(str or , optional) — The tag parser to registerif name is given, will be treated as aliasenv
(bool, optional) — Whether we should pass environment to the parserraw
(bool, optional) — Whether we should keep the body of the tag raw
Returns
The registered parser for the tag or a decorator
method
parse
(
env
, token
, parser
)
Calling the parser functions to parse the tags
Parameters
env
(Environment) — The environmenttoken
(Token) — The token matches the tag nameparser
(Parser) — The parser
Returns (Node)
The parsed node