So I am aiming to use John Resig's templating engine.
I need to pass the function a variable containing the "template". However, the problem is that I need to pass something like:
<script>
console.log("Double quotes");
</script>
<script>
console.log('single');
</script>
<iframe src="http://example.com/?<%=SOME_VARIABLE%>" frameborder="0"></iframe>
<div>I think I'm going to break</div>
<% for ( var i = 0; i < users.length; i++ ) { %>
<li><a href="<%=users[i]%>"><%=users[i]%></a></li>
<% } %>
<iframe src='http://example.com/?<%=SOME_VARIABLE%>' frameborder="0"></iframe>
<div>I think I"m going to break</div>
<% for ( var i = 0; i < users.length; i++ ) { %>
<li><a href='<%=users[i]%>'><%=users[i]%></a></li>
<% } %>
The thing that seems to break is:
<script>
console.log('single');
</script>
With this bit of code being passed through the Regex it fails. It is important that I am able to pass any of the above code and have it not break. Any ideas?