comparison tests/test-command-template.t @ 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 867d6ba2353d
comparison
equal deleted inserted replaced
28694:9a6fa1d93bc8 28695:cc103bd0dbf9
3691 $ hg log -T "invalid type: {rev|utf8}\n" -r0 3691 $ hg log -T "invalid type: {rev|utf8}\n" -r0
3692 abort: template filter 'utf8' is not compatible with keyword 'rev' 3692 abort: template filter 'utf8' is not compatible with keyword 'rev'
3693 [255] 3693 [255]
3694 3694
3695 $ cd .. 3695 $ cd ..
3696
3697 Test that template function in extension is registered as expected
3698
3699 $ cd a
3700
3701 $ cat <<EOF > $TESTTMP/customfunc.py
3702 > from mercurial import registrar
3703 >
3704 > templatefunc = registrar.templatefunc()
3705 >
3706 > @templatefunc('custom()')
3707 > def custom(context, mapping, args):
3708 > return 'custom'
3709 > EOF
3710 $ cat <<EOF > .hg/hgrc
3711 > [extensions]
3712 > customfunc = $TESTTMP/customfunc.py
3713 > EOF
3714
3715 $ hg log -r . -T "{custom()}\n" --config customfunc.enabled=true
3716 custom
3717
3718 $ cd ..