Add support for Wikibase and dependent extensions

Also introduce some basic template var substitution.