##// END OF EJS Templates
registrar: add templatekeyword to mark a function as template keyword (API)...
FUJIWARA Katsunori -
r28538:009f58f1 default
parent child Browse files
Show More
@@ -35,6 +35,7 b' from . import ('
35 35 hg,
36 36 hook,
37 37 revset,
38 templatekw,
38 39 ui as uimod,
39 40 util,
40 41 )
@@ -758,6 +759,7 b' extraloaders = ['
758 759 ('cmdtable', commands, 'loadcmdtable'),
759 760 ('filesetpredicate', fileset, 'loadpredicate'),
760 761 ('revsetpredicate', revset, 'loadpredicate'),
762 ('templatekeyword', templatekw, 'loadkeyword'),
761 763 ]
762 764
763 765 def _dispatch(req):
@@ -161,3 +161,33 b' class filesetpredicate(_funcregistrarbas'
161 161 def _extrasetup(self, name, func, callstatus=False, callexisting=False):
162 162 func._callstatus = callstatus
163 163 func._callexisting = callexisting
164
165 class _templateregistrarbase(_funcregistrarbase):
166 """Base of decorator to register functions as template specific one
167 """
168 _docformat = ":%s: %s"
169
170 class templatekeyword(_templateregistrarbase):
171 """Decorator to register template keyword
172
173 Usage::
174
175 templaetkeyword = registrar.templatekeyword()
176
177 @templatekeyword('mykeyword')
178 def mykeywordfunc(repo, ctx, templ, cache, revcache, **args):
179 '''Explanation of this template keyword ....
180 '''
181 pass
182
183 The first string argument is used also in online help.
184
185 'templatekeyword' instance in example above can be used to
186 decorate multiple functions.
187
188 Decorated functions are registered automatically at loading
189 extension, if an instance named as 'templatekeyword' is used for
190 decorating in extension.
191
192 Otherwise, explicit 'templatekw.loadkeyword()' is needed.
193 """
@@ -574,5 +574,11 b' keywords = {'
574 574 'tags': showtags,
575 575 }
576 576
577 def loadkeyword(ui, extname, registrarobj):
578 """Load template keyword from specified registrarobj
579 """
580 for name, func in registrarobj._table.iteritems():
581 keywords[name] = func
582
577 583 # tell hggettext to extract docstrings from these functions:
578 584 i18nfunctions = keywords.values()
General Comments 0
You need to be logged in to leave comments. Login now