JS HereDoc

by Michel Plungjan

JavaScript

var new_comment; /*<<<EOF 
        <li class="photobooth-comment">
           <span class="username">
              <a href="#">You</a>
           </span>
           <span class="comment-text">
              $text
           </span>
           <span class="comment-time">
              2d
           </span>
        </li>
    EOF*/
    // note the script tag here is the hardcoded as the SECOND tag 
    new_comment=document.getElementsByTagName('script')[1].innerHTML.split("EOF")[1]; 
    alert(new_comment.replace('$text','Here goes some text'));