Rahul
Rahul

Reputation: 77876

What does "<%= data %>" mean in HTML

I see a tag like <%= data %> in a plain HTML file. Below is the exact code line with this context. Does any one know what does that refers to? can we do something like that in HTML?

<textarea class="userProfile-status-field userProfile-edit" maxlength="80"><%= status %></textarea>

It looks like a server tag or server code block which we generally do in ASP.NET but not sure what that does in HTML.

Upvotes: 0

Views: 103

Answers (3)

Bhojendra Rauniyar
Bhojendra Rauniyar

Reputation: 85545

The tag you're seeing is some sort of javascript template engine.

To learn more, just google about javascript template engine.

You can check the MDN docs to see how to create template engine.

Check this site to see fully demonstrated example on such topic.

Upvotes: 1

Vitor Rigoni
Vitor Rigoni

Reputation: 573

Your assumption is correct.

A <%= %> is an ASP.NET/Classic ASP tag, and its a shortcut for <% Response.Write(data); %>. There are many others tags as well like <%# %> or <%: %> and each suit an specific purpose.

The answer on this question ASP.NET "special" tags provides much information about them.

On a plain HTML file we have two options: it was copied from an aspx file and was forgotten there or someone is using a templating framework for JS, as suggested. This link http://www.sitepoint.com/overview-javascript-templating-engines/ provides more information about javascript templating engines (although I've never seen one using <%= %>)

Upvotes: 1

Alaister Young
Alaister Young

Reputation: 357

This usually is a template syntax for evaluating variables or functions and then putting the result into HTML.

Upvotes: 0

Related Questions