For one of my pretty bog standard portable templates, I want to build in an automatic return that uses #if, #expr and #explode. I've researched it a bit, but can't quite figure out how to combine the three in Lua in the template.
The wikitext would look something like this: (not tested)
{{#if: {{{prev|}} | [[{{prev}}]] | [[ {{{t}}} {{#expr:{{#explode:{{PAGENAME}}| |-1}}-1}} ]] }} }}
Meaning, that if a previous issue name (prev) is entered, it should give whatever input is given, but if not, it automatically gives the series title (t) plus the pagename's number, minus 1.
The Prev/next portion of the template is cribbed from Game of Thrones wiki.
See here for a usage example.