Template:LiveSampleURL

  • Revision slug: Template:LiveSampleURL
  • Revision title: Template:LiveSampleURL
  • Revision id: 425009
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment add an optional parameter to specify the URL instead of using the current page

Revision Content

<% // Returns the URL used to access as a live sample the code // at a given ID. // // Parameters: // // $0 The ID of the sample's section or containing block. // $1 The URL from which to pull the sample; if not provided, // the current page is assumed. var base = $1 || env.url; base = base.replace('developer.mozilla.org', 'mdn.mozillademos.org'); // HACK: This may be the result of server misconfiguration. base = base.replace('http://', 'https://'); %> <%= base + '$samples/' + $0 + '?revision=' + env.revision_id %>

Revision Source

<%
// Returns the URL used to access as a live sample the code
// at a given ID.
//
// Parameters:
//
// $0   The ID of the sample's section or containing block.
// $1   The URL from which to pull the sample; if not provided,
//      the current page is assumed.

var base = $1 || env.url;

base = base.replace('developer.mozilla.org', 'mdn.mozillademos.org');
// HACK: This may be the result of server misconfiguration. 
base = base.replace('http://', 'https://'); 
%>
<%= base + '$samples/' + $0 + '?revision=' + env.revision_id %>
Revert to this revision