In case someone reads this thread in the future: it is possible to pass template parameters to an extension using parser functions.
I created a parser function that just returns the extension tag. The parser function receives the template parameters already replaced.
A strange thing is that if a parameter is optional in the template, the parser function receives that parameter as {{{3}}}, {{{4}}}. I used a code like this to ignore it inside the parser function:
if (strpos($filename, "{{{") === 0) $filename = '';