Search code examples
mediawikiiframetemplatesmarkup

Make a template page on MediaWiki which substitutes given arguments to an iframe


I'm using the Iframe plugin and the following code to embed a video from VK:

<div style="float:right; margin: 0px 0px 25px 25px;"><iframe k="vk"
 p="video_ext.php?oid=349530500&id=456239067&hash=4561ee8657098af3&hd=2"
w="640" h="360" allowfullscreen="1" /></div> 

But I would like to write something like this instead

{{VkVideo|video_ext.php?oid=349530500&id=456239067&hash=4561ee8657098af3&hd=2}}

What should I write in Template:VkVideo? If I write the following code

<div style="float:right; margin: 0px 0px 25px 25px;"><iframe k="vk"
 p="{{{1}}}"
w="640" h="360" allowfullscreen="1" /></div> 

it does not substitute the argument for some reason. So the HTML of the page where I use the template contains this code:

<div style="float:right; margin: 0px 0px 25px 25px;"><iframe id="Iframe1"
data-src="https://vk.com/{{{1}}}"
data-delay="50" width="640" height="360" frameborder="0" allowfullscreen=""></iframe></div>

Solution

  • Extension tags do not take template arguments as they are expected to output HTML which needs to be shielded from template processing. Try

    <div style="float:right; margin: 0px 0px 25px 25px;">{{#tag:iframe||k=vk|p={{{1}}}|w=640|h=|360|allowfullscreen=1}}</div>
    

    (see here)