A multiple-line string in JavaScript


SUBMITTED BY: YouKnowNothing

DATE: Jan. 11, 2016, 10:36 a.m.

FORMAT: JavaScript

SIZE: 362 Bytes

HITS: 2122

  1. //Set the multi-line HTML data
  2. var htmlData = RemoveOuter(function(){/*!
  3. <h2>Home</h2>
  4. <p>Hello!</p>
  5. */});
  6. //Set the body to the html data
  7. $("body").html(htmlData);
  8. //Removes the functions (allowing multiple line strings)
  9. function RemoveOuter(f){
  10. return f.toString().replace("*/}", '').replace("function (){/*!", '').replace(/^\s+|\s+$/g, '');
  11. }

comments powered by Disqus