comparison mercurial/templatefilters.py @ 36246:9ee10b3284da

templatefilters: add dirname() filter This is different from stripdir() in that the last component is always removed.
author Yuya Nishihara <yuya@tcha.org>
date Sun, 07 Jan 2018 12:09:33 +0900
parents 6d65cef5b038
children b2e54b257832
comparison
equal deleted inserted replaced
36245:c6ce479f7a28 36246:9ee10b3284da
97 97
98 @templatefilter('count') 98 @templatefilter('count')
99 def count(i): 99 def count(i):
100 """List or text. Returns the length as an integer.""" 100 """List or text. Returns the length as an integer."""
101 return len(i) 101 return len(i)
102
103 @templatefilter('dirname')
104 def dirname(path):
105 """Any text. Treats the text as a path, and strips the last
106 component of the path after splitting by the path separator.
107 """
108 return os.path.dirname(path)
102 109
103 @templatefilter('domain') 110 @templatefilter('domain')
104 def domain(author): 111 def domain(author):
105 """Any text. Finds the first string that looks like an email 112 """Any text. Finds the first string that looks like an email
106 address, and extracts just the domain component. Example: ``User 113 address, and extracts just the domain component. Example: ``User