Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/templatefuncs.py @ 43735:fa246ada356b
templates: make {indent("", " ")} be empty
indent() is documented to indent all non-empty lines, but it made an
exception for the first line, which always got indented. I also made
indent() not indent the first line even if an indent override was
given for the first line. I think that is what one would usually want.
Differential Revision: https://phab.mercurial-scm.org/D7432
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Fri, 15 Nov 2019 10:16:27 -0800 |
parents | d783f945a701 |
children | fc1fa3a07af6 |
comparison
equal
deleted
inserted
replaced
43734:0fd9e7a1cf36 | 43735:fa246ada356b |
---|---|
308 raise error.ParseError(_(b"indent() expects two or three arguments")) | 308 raise error.ParseError(_(b"indent() expects two or three arguments")) |
309 | 309 |
310 text = evalstring(context, mapping, args[0]) | 310 text = evalstring(context, mapping, args[0]) |
311 indent = evalstring(context, mapping, args[1]) | 311 indent = evalstring(context, mapping, args[1]) |
312 | 312 |
313 firstline = indent | |
313 if len(args) == 3: | 314 if len(args) == 3: |
314 firstline = evalstring(context, mapping, args[2]) | 315 firstline = evalstring(context, mapping, args[2]) |
315 else: | 316 |
316 firstline = indent | 317 return templatefilters.indent(text, indent, firstline=firstline) |
317 | |
318 # the indent function doesn't indent the first line, so we do it here | |
319 return templatefilters.indent(firstline + text, indent) | |
320 | 318 |
321 | 319 |
322 @templatefunc(b'get(dict, key)') | 320 @templatefunc(b'get(dict, key)') |
323 def get(context, mapping, args): | 321 def get(context, mapping, args): |
324 """Get an attribute/key from an object. Some keywords | 322 """Get an attribute/key from an object. Some keywords |