Template:EmbedLiveSample

  • Revision slug: Template:EmbedLiveSample
  • Revision title: Template:EmbedLiveSample
  • Revision id: 342389
  • Created:
  • Creator: trevorh
  • Is current revision? No
  • Comment Added optional screenshot, creates table with Screenshot and Live sample

Revision Content

<% // Embeds a live sample given the ID of its header block. // // Parameters: // $0 - The ID of the header block containing the sample // $1 - The width of the iframe (optional) // $2 - The height of the iframe (optional) // $3 - The url of a screenshot of the sample working as intended (optional) // // See also : LiveSampleLink var str = ""; var widthHeight = ""; if ($1 && $2) { widthHeight = "width='" + $1 + "' height='" + $2 + "' "; } var liveSample = ''; if ($3) { str += ''; str += ''; str += ''; str += ''; str += ''; str += ''; str += '
ScreenshotLive sample
' + liveSample + '
'; } else { str += liveSample; } %> <%- str %>

Revision Source

<%
// Embeds a live sample given the ID of its header block.
//
// Parameters:
//  $0 - The ID of the header block containing the sample
//  $1 - The width of the iframe (optional)
//  $2 - The height of the iframe (optional)
//  $3 - The url of a screenshot of the sample working as intended (optional)
//
// See also : LiveSampleLink
 
var str = "";
 
var widthHeight = "";
if ($1 && $2) {
    widthHeight = "width='" + $1 + "' height='" + $2 + "' ";
}
var liveSample = '<iframe  frameborder="0" ' + widthHeight + 'src="' + template('LiveSampleURL', [$0]) + '"></iframe>';
if ($3) {
    str += '<table><thead><tr>';
    str += '<th scope="col" style="text-align: center;">Screenshot</th>';
    str += '<th scope="col" style="text-align: center;">Live sample</th>';
    str += '</tr></thead><tbody><tr>';
    str += '<td><img alt="" class="internal" src="' + $3 + '" /></td>';
    str += '<td>' + liveSample + '</td>';
    str += '</tr></tbody></table>';
} else {
    str += liveSample;
}
%>
<%- str %>
Revert to this revision