{{subst:#ifexpr:{{{1}}}>0 |{{subst:subst1}}pipeN{{subst:pipe1}}{{subst:#expr:{{{1}}}-1}}{{subst:rightbraces1}} |{{subst:pipe1}} }}

Substituting this template produces one or more new substitution template calls, allowing recursive change of a page, see Help:Recursive conversion of wikitext.
  • Note: This template works less efficiently with the new preprocessor which (as I know it) doesn't double parse, so that "subst1" and "pipe1" fixes are no longer needed. See template:pipeN-new.