What Is The <%= %> Tag In Html?
<%= user.fullname %>
Solution 1:
What is the
<%= %>
tag in html?
There is none. There are several templating engines that use <%
and %>
to delimit either templates or code blocks, though: Active Server Pages (ASP), JavaServer Pages (JSP), probably others. Those usually do server-side processing and replace the text in the <% ... %>
with whatever should go there.
For instance, in your example
<h1><%= user.fullname %></h1>
if the user
object's fullname
property is "Joe Bloggs"
when the resource is requested, the engine will swap that in for that token before sending the text, so what the browser actually sees is
<h1>Joe Bloggs</h1>
In your case, as you point out, the processing is happening client-side. Your <% ... %>
tokens are within <script type="text/template">...</script>
blocks, so the <
isn't at all special. (Before DCoder pointed that out to me, I had a complex explanation here of why it worked...but then, er, DCoder pointed out that they were in script
blocks, so...)
DCoder also identified that these are templates being handled by backbone.js, which reuses underscore.js's templates.
Solution 2:
What is the
<%= %>
tag in html?
Like T.J. Crowder said, that is not an HTML tag, it comes from a client-side templating engine that happens to use these expressions to indicate the beginning/end of dynamically interpolated content.
How do I find out what templating engine is used? (it's not ASP or JSP)
Based on the fact that your page loads backbone.js, the template engine is most likely backbone's template engine, which is actually borrowed from underscore.js.
Solution 3:
That's either ASP.NET or JavaScript markup that you're seeing.
Solution 4:
That's usually a form of server side programming. It could be JSP (in Java), ASP or even PHP (with asp tags enabled). It will replace the contents (at server response time) of the <%= %>
with the server side variable's value.
Solution 5:
The statement '<%= user.fullname %>' evaluates the property 'user.fullname' and renders it as a string. The 'user' object could exist as a property on the page or could be a static class type.
Post a Comment for "What Is The <%= %> Tag In Html?"