[PATCH] templates: add substring and string length operations
Yuya Nishihara
yuya at tcha.org
Fri Jul 14 22:27:01 EDT 2017
On Fri, 14 Jul 2017 16:27:49 -0700, Rodrigo Damazio via Mercurial-devel wrote:
> On Fri, Jul 14, 2017 at 3:48 PM, Rodrigo Damazio Bovendorp <
> rdamazio at google.com> wrote:
> > # HG changeset patch
> > # User Rodrigo Damazio Bovendorp <rdamazio at google.com>
> > # Date 1500072378 25200
> > # Fri Jul 14 15:46:18 2017 -0700
> > # Node ID 0ccebbd04efbd672fc71df7f52ec243057cbed7d
> > # Parent c0d8de2724ce6240d2a4241aff78ce2ee92359c2
> > templates: add substring and string length operations
> > + at templatefilter('strlen')
> > +def stringlen(text):
> > + """Any text. Turns the value into its length."""
> > + return len(text)
You can use "str|count" instead.
> > + at templatefunc('substr(text, start[, end])')
I think substr() generally takes offset and length, not start:end range.
More information about the Mercurial-devel
mailing list