comparison mercurial/help/templates.txt @ 30730:107014f4848b

help: apply the section headings from revsets to templates Unlike filesets, there are a few distinct headings that are not shared with revsets. But common names are used where possible.
author Matt Harbison <matt_harbison@yahoo.com>
date Sun, 08 Jan 2017 02:43:01 -0500
parents 8e42dfde93d1
children b8a188a6f191
comparison
equal deleted inserted replaced
30729:a4bc8fff67fc 30730:107014f4848b
14 expansion:: 14 expansion::
15 15
16 $ hg log -r1 --template "{node}\n" 16 $ hg log -r1 --template "{node}\n"
17 b56ce7b07c52de7d5fd79fb89701ea538af65746 17 b56ce7b07c52de7d5fd79fb89701ea538af65746
18 18
19 Keywords
20 ========
21
19 Strings in curly braces are called keywords. The availability of 22 Strings in curly braces are called keywords. The availability of
20 keywords depends on the exact context of the templater. These 23 keywords depends on the exact context of the templater. These
21 keywords are usually available for templating a log-like command: 24 keywords are usually available for templating a log-like command:
22 25
23 .. keywordsmarker 26 .. keywordsmarker
30 You can also use a chain of filters to get the desired output:: 33 You can also use a chain of filters to get the desired output::
31 34
32 $ hg tip --template "{date|isodate}\n" 35 $ hg tip --template "{date|isodate}\n"
33 2008-08-21 18:22 +0000 36 2008-08-21 18:22 +0000
34 37
38 Filters
39 =======
40
35 List of filters: 41 List of filters:
36 42
37 .. filtersmarker 43 .. filtersmarker
38 44
39 Note that a filter is nothing more than a function call, i.e. 45 Note that a filter is nothing more than a function call, i.e.
40 ``expr|filter`` is equivalent to ``filter(expr)``. 46 ``expr|filter`` is equivalent to ``filter(expr)``.
41 47
48 Functions
49 =========
50
42 In addition to filters, there are some basic built-in functions: 51 In addition to filters, there are some basic built-in functions:
43 52
44 .. functionsmarker 53 .. functionsmarker
54
55 Infix
56 =====
45 57
46 We provide a limited set of infix arithmetic operations on integers:: 58 We provide a limited set of infix arithmetic operations on integers::
47 59
48 + for addition 60 + for addition
49 - for subtraction 61 - for subtraction
57 expr % "{template}" 69 expr % "{template}"
58 70
59 As seen in the above example, ``{template}`` is interpreted as a template. 71 As seen in the above example, ``{template}`` is interpreted as a template.
60 To prevent it from being interpreted, you can use an escape character ``\{`` 72 To prevent it from being interpreted, you can use an escape character ``\{``
61 or a raw string prefix, ``r'...'``. 73 or a raw string prefix, ``r'...'``.
74
75 Aliases
76 =======
62 77
63 New keywords and functions can be defined in the ``templatealias`` section of 78 New keywords and functions can be defined in the ``templatealias`` section of
64 a Mercurial configuration file:: 79 a Mercurial configuration file::
65 80
66 <alias> = <definition> 81 <alias> = <definition>
91 nodedate = "{node|short}: {date(date, "%Y-%m-%d")}\n" 106 nodedate = "{node|short}: {date(date, "%Y-%m-%d")}\n"
92 107
93 defines a template, ``nodedate``, which can be called like:: 108 defines a template, ``nodedate``, which can be called like::
94 109
95 $ hg log -r . -Tnodedate 110 $ hg log -r . -Tnodedate
111
112 Examples
113 ========
96 114
97 Some sample command line templates: 115 Some sample command line templates:
98 116
99 - Format lists, e.g. files:: 117 - Format lists, e.g. files::
100 118