##master-page:HelpTemplate #format wiki #language en <> == Create a custom filter == === Objective === This page shows you how to create a custom filter. For that, we are going to write a python script, and add it as an extension. Our filter will convert the text passed to it to uppercase. ==== Write script ==== First step, write the script and save it somewhere. {{{#!python from mercurial import templatefilters def upper(s): return s.upper() def extsetup(ui): templatefilters.filters["upper"] = upper }}} ==== Add Extension ==== In mercurial.ini, add this script under the [extensions] section. {{{ [extensions] upper = ~/.hgext/myfeature.py }}} (if this doesn't work, see [[UsingExtensions|Using Mercurial Extensions]] for help on configuring extensions) === Example === {{{ >hg tip --template "{author|upper}\n" GUIDO VAN ROSSUM }}} ---- CategoryDeveloper