Mercurial > public > mercurial-scm > hg
comparison mercurial/templater.py @ 28695:cc103bd0dbf9
registrar: add templatefunc to mark a function as template function (API)
This patch also adds loadfunction() to templater, because this
combination helps to figure out how they cooperate with each other.
Listing up loadfunction() in dispatch.extraloaders causes implicit
loading template function at loading (3rd party) extension.
This patch explicitly tests whether templatefunc decorator works as
expected, because there is no bundled extension, which defines
template function.
This change requires that "templatefunc" attribute of (3rd party)
extension is registrar.templatefunc or so.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Wed, 30 Mar 2016 02:10:44 +0900 |
parents | 29c249dfb4ef |
children | efa192203623 |
comparison
equal
deleted
inserted
replaced
28694:9a6fa1d93bc8 | 28695:cc103bd0dbf9 |
---|---|
1067 if os.path.isfile(mapfile): | 1067 if os.path.isfile(mapfile): |
1068 return style, mapfile | 1068 return style, mapfile |
1069 | 1069 |
1070 raise RuntimeError("No hgweb templates found in %r" % paths) | 1070 raise RuntimeError("No hgweb templates found in %r" % paths) |
1071 | 1071 |
1072 def loadfunction(ui, extname, registrarobj): | |
1073 """Load template function from specified registrarobj | |
1074 """ | |
1075 for name, func in registrarobj._table.iteritems(): | |
1076 funcs[name] = func | |
1077 | |
1072 # tell hggettext to extract docstrings from these functions: | 1078 # tell hggettext to extract docstrings from these functions: |
1073 i18nfunctions = funcs.values() | 1079 i18nfunctions = funcs.values() |