Template:Embed text

  • Revision slug: Template:Embed_text
  • Revision title: Template:Embed text
  • Revision id: 290727
  • Created:
  • Creator: Jeremie
  • Is current revision? No
  • Comment

Revision Content

<% /* * 2 parameters expected * $0 : the file name to embed * $1 : the syntaxe color to apply */   var found = false;   var brush = [bash, shell, css, java, js, jscript, javascript, php, py, python, sql, xml, xhtml, xslt, html, xhtml]   var syntaxe = "txt";     if (brush.indexOf($1) > -1) {   syntaxe = $1;   }     env.files.forEach(function(aFile) {     if ($0 === aFile.filename) {       found = true; %>
<%= mdn.getFileContent(aFile) %>
<%     }   });     if (!found) { %>

Unable to find file <%= $0 %>

<%   } %>

Revision Source

<% 
/* 
 * 2 parameters expected
 * $0 : the file name to embed
 * $1 : the syntaxe color to apply
 */
  var found = false;
  var brush = [bash, shell, css, java, js, jscript, javascript, php, py, python, sql, xml, xhtml, xslt, html, xhtml]
  var syntaxe = "txt";
  
  if (brush.indexOf($1) > -1) {
      syntaxe = $1;
  }
  
  env.files.forEach(function(aFile) {
    if ($0 === aFile.filename) {
      found = true;
%>
<pre class="brush: <%= syntaxe %>"><%= mdn.getFileContent(aFile) %></pre>
<%
    }
  });
  
  if (!found) {
%><p>Unable to find file <em><%= $0 %></em></p><%
  }
%>
Revert to this revision