I stumbled upon https://codereview.stackexchange.com/questions/10610/refactoring-javascript-into-pure-functions-to-make-code-more-readable-and-mainta and I don't understand the answer since the user uses an @ symbol in a way I've never seen before. What does it do when attached to the if keyword? Can you attach it to other keywords?
Asked
Active
Viewed 5,326 times
2 Answers
12
It's not a JavaScript thing. It's a symbol used by whatever templating system that answer was referring to. Note that the <script>
element has type text/html
, which will prevent browsers from paying any attention to its contents.
Some other JavaScript code will find that script and fetch its innerHTML
in order to merge the template with some data to create ... well whatever that template makes.
-
1The templating system in question is Razor in .Net MVC3 – Peter T. LaComb Jr. Jun 30 '12 at 23:07
3
@: syntax in Razor
Said by @StriplingWarrior at Using Razor within JavaScript
It is razor code, not javascript, if you are interested in razor check: http://weblogs.asp.net/scottgu/archive/2010/07/02/introducing-razor.aspx

Community
- 1
- 1

Mario Corchero
- 5,257
- 5
- 33
- 59
-
Razor syntax starts code blocks with a @ character and does not require explicit closing of the code-block. – Mario Corchero Jun 30 '12 at 23:11