Open OscarGodson opened 8 years ago
Sadly the is no look ahead in regex, therefore there is no way for it to know that there is a script inside this string.
Hm, out of curiosity then how do the other templating languages do this? For example that identical code works in Mustache just changing it to {{
and }}
instead of <%=
and %>
It's a scoping mechanism. Those symbols determine that code begins and ends, code which has it's own syntax. For strings there is no further syntax to be parsed through, you can just have a string.
There is no way to differentiate when `"<%= ... %>" is meant for code and when it coincidentally happens as a string, therefore the syntax compromises and says it's always a string because it doesn't know any better.
If my explanation does not suffice as it might be confusing, try to learn more about regular expression or even how compilers and interpreters "tokenize" your code. Hope this helped any way.
For example
It's a solid color inside of the quotes. It should have different colors for things like
<%=
and%>
andthumbnail