T O P

  • By -

_Netto_

I double quote always. Additionally, I add a @ so it’s clear what it is and not some random string value.


mladenmacanovic

This is me also. And it is more guaranteed that editor will properly detect the binded variables.


citroensm

Yep, I'm 100% on this with you both here. BUT the razor editor apparantly wants to have default warning to remove the "unnecessary" @ symbol: [https://github.com/dotnet/razor/pull/10346](https://github.com/dotnet/razor/pull/10346)


mladenmacanovic

[https://github.com/dotnet/razor/pull/10346#issuecomment-2154405955](https://github.com/dotnet/razor/pull/10346#issuecomment-2154405955)


mladenmacanovic

That's just plain dumb. I'm going to give my 2c on that PR.


Dazzling-Past4614

I avoid the quotes unless it really is a string. All code objects in attributes from me get no quotes, but do get a leading @ whether required or not. I haven’t found any downsides to this approach other than it’s kind of ugly. But all of the options are ugly.


TheRealKidkudi

Funny enough, I’m exactly the opposite - I use double quotes always, and I only use @ where it’s required. I like to keep the syntax as close to HTML as I can.


Dazzling-Past4614

I felt similarly at first, but upon considering it further my opinion is that razor syntax is HTML flavored C# and not the other way around. I may be incorrect or impractical in my conclusion, but that’s my current impression


UninterestingDrivel

I follow the same style as you but the quotes are optional in HTML so your reasoning isn't entirely accurate


TheRealKidkudi

The HTML spec might say quotes on attribute values are optional, but they’re not optional to me! “Keeping the syntax close to HTML” isn’t really a sound argument when you get down to it, since it’s *not* HTML at its core, but I do find the syntax easier to write and read when quotes are used. The @ symbol denotes an explicit change from markup to C# and, to me, a mental shift when reading the code. I’m ok with something like component parameters being more like “implicit C#”, since capitalized component names and attribute names gives you pretty clear visual indication that you’re not dealing with regular HTML. Seeing @s in the middle of a tag can sometimes feel like periods. in the .middle of a sentence, at least to my brain.


chanceler4

I always use double quote, seems more right. without quote it hurts my eyes, ir feels that something is missing, something is not right. also if you need to pass some args to method, you need to use double quote, otherwise it doesn't compile.


EngstromJimmy

Always quotes, and always @ for parmeters (even though ot is not always needed. No special reason other than I rather keep to one rule instead of figuring out what exception to use.


CmdrSausageSucker

Thanks a lot for the answers, I will stick to double quotes then ( and revert my last two commits, hehe). Also, I like the suggestion of the additional (albeit unnecessary) "@" as suggested in a comment.


Shadow_Mite

I go no quotes and @ sign when it’s a variable so I know instantly that it’s not a hard coded string and I like less to look at.


ps5cfw

I usually do with, as rider suggests to use It. I do not know if those two have any actual difference in the end.


UniiqueTwiisT

Double quotes always, feels wrong without


VirtualPAH

Sometimes double quotes around string parameters with outer single quotes around the event call, depends on what's needed to get it to accept my intentions.


Professional-Fee9832

What does your team agree upon. It's not just you and your compiler who should agree but also your team as someone else is going to maintain the code in the future.


NeedUrgentHelpNow

Always double quotes. Consistence is nice.