Reputation: 521
I'm trying to bind a data attribute as follows:
@Html.Label("test", new { data_test = "{{vm.test}}" })
When rendered, what I see is:
<label data-test for="test">test</label>
How do I escape the curly braces so that they're rendered on the page? Some things a I've tried are:
Upvotes: 2
Views: 4091
Reputation: 391
If you need to display the curly braces, as when you're explaining handlebar logic and you don't need any other constructs:
Code:
<note>Example: @("{{object.exampleField}}")</note>
Displayed:
Example: {{object.exampleField}}
Upvotes: 1
Reputation:
To write curly braces "{}" in razor use the combination of "at" and "colon". Example: @:{
I had just figured it out while using handle bars.
And to write "@" use one more "at" sign.
Example: @@
I hope it helps the new ones who are looking for it!
Upvotes: 0
Reputation: 2539
Inside a code block, you cannot use @
characters to create more code blocks.
something like:
@Html.Label("test", new { data_test = "{{@vm.test}}" })
Upvotes: 0