equal
deleted
inserted
replaced
870 |
870 |
871 # methods to interpret top-level template (e.g. {x}, {x|_}, {x % "y"}) |
871 # methods to interpret top-level template (e.g. {x}, {x|_}, {x % "y"}) |
872 methods = exprmethods.copy() |
872 methods = exprmethods.copy() |
873 methods["integer"] = exprmethods["symbol"] # '{1}' as variable |
873 methods["integer"] = exprmethods["symbol"] # '{1}' as variable |
874 |
874 |
|
875 class _aliasrules(parser.basealiasrules): |
|
876 """Parsing and expansion rule set of template aliases""" |
|
877 _section = _('template alias') |
|
878 _parse = staticmethod(_parseexpr) |
|
879 |
|
880 @staticmethod |
|
881 def _trygetfunc(tree): |
|
882 """Return (name, args) if tree is func(...) or ...|filter; otherwise |
|
883 None""" |
|
884 if tree[0] == 'func' and tree[1][0] == 'symbol': |
|
885 return tree[1][1], getlist(tree[2]) |
|
886 if tree[0] == '|' and tree[2][0] == 'symbol': |
|
887 return tree[2][1], [tree[1]] |
|
888 |
|
889 def expandaliases(tree, aliases): |
|
890 """Return new tree of aliases are expanded""" |
|
891 aliasmap = _aliasrules.buildmap(aliases) |
|
892 return _aliasrules.expand(aliasmap, tree) |
|
893 |
875 # template engine |
894 # template engine |
876 |
895 |
877 stringify = templatefilters.stringify |
896 stringify = templatefilters.stringify |
878 |
897 |
879 def _flatten(thing): |
898 def _flatten(thing): |