How to "escape" the @ in Razor

Asked

Viewed 45 times

3

I am trying to leave @ as string. Here is the code:

hint: {
mentions: ['Pedro', 'Tiago', 'João', 'Maria'],
match: /\B@(\w*)$/, // Problema com @
search: function (keyword, callback) {
    callback($.grep(this.mentions, function (item) {
        return item.indexOf(keyword) == 0;
    }));
},
content: function (item) {
    return '@' + item;  // Problema com @
    }    
},

Marked lines face the problem of @.

The problem is @, it understands as template syntax. How to leave it as string ?

1 answer

4


Ironically (or not) who makes the escape from @ is the very @.

Use @@ should work.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.