Create prefixes for tag helpers
This will involve modifying the @taghelper "assemblyname" directive to be something like @taghelper "assemblyname" "prefix".
This in turn will enforce certain restrictions on generating/understanding tag helpers.
Ex: If you do @taghelper "MyAssembly" "r-" that means that all tag helpers in _MyAssembly_ must be prefixed with _r-_.
<r-my-taghelper /> <!-- Runs the my-taghelper helper -->
Should discuss if we want to support prefixes at the C# tag helper level.
nit: this looks much more like a prefix than a namespace. let's use term "prefix" going forward.
I think that the attributes should be italicized in the editor so I can tell what's rendered and what isn't.
I prefer the standard attribute syntax. Nothing more "natural" than:
<li><a controller="Home" action="Index">Home</a></li>
This will help new developers coming from standard web-development to dive in really quick. Without prefixes.
Personally I think 'data-asp-' or 'data-customprefix-' as a prefix feels more HTML5 standard, and less likely to be confused when integrating with client-side technologies. Great feature though!
i prefer like this:
<li><a controller="Home" action="Index">Home</a></li>
I would like data-asp- or asp:-prefix
I think asp- would be a good prefix. If there is no prefix, it would be unclear that ASP.NET is going to process these attributes. If you're using italics like Scott suggests, I think that's a VS only solution.
+1 for the no-prefix version. It's the cleanest, most obvious format suggested so far in my opinion. The IDE can highlight, with coloring or italics or whatever, that these are "special" server-side attributes.
The prefixes make them look like part of a client-side framework, like angular's ng-whatever="..." attributes. Putting data-whatever="..." on them seems like it would confuse the issue, since that's specifically for client side code and there's nothing to stop me from using data-asp-controller="..." as a perfectly valid data attribute in an HTML app today. It wouldn't be immediately obvious whether a given data- attribute was part of some Bootstrap plumbing, my own custom stuff, or a server-side tag helper.
I don't like the asp: prefix idea because the colon just looks wrong in an HTML attribute name. If anything, I would say a asp- prefix is probably the least-bad alternative after no prefix.
I'd suggest a custom prefix as this aligns correctly with the custom elements draft.
E.G. <asp-a> for anchor tags.
Attribute names do not need to prefix WRT the custom element draft IIRC.
I do not think they should be just plain attributes... it is confusing to me at that point what is going on, is this being processed on the server or the client? There needs to be a crystal-clear distinction. asp: makes me shudder and brings back bad memories of WebForms, better to not further confuse people by making it look like that.
Remembering that we are talking about ASP_.NET_, and that it runs on the server-side, I think it should either be aspnet- or server-. I think aspnet- would be better, because then it would allow other companies to build their own taghelpers that have their branding in it. For example, I can see Telerik building a <table> taghelper for Kendo UI that would let you build HTML to look like a normal table but render a Kendo Grid. So you'd have code like: <table kendo-datasource="datasourcename"></table>.
Just my $0.02.
I agree on the prefix helping identify responsibility, and like the idea of using a colon instead of a dash to make it clear, separating it from "regular" attributes.
I vote for having a prefix. I'm not traumatized by web forms, so for me something like this looks OK:
<prefix:tag attribute="value" />
I vote against using a dash because that's part of the requirement for custom elements (http://www.w3.org/TR/custom-elements/ -- see section 4).
I'd prefer a prefixed version of some sort.
if the intention is to approach ppl to HTML5, I prefer the prefixed version. Standard tags attribute as well custom tags could be leaved untouched. Home <a href="&routename=myway,&direction=up>New way where 'direction' is a variable defined on the route named 'myway'. The tag attribute does not appear magically, what will be changed is its value.
btw... good new for ASP.NET
Ups..... part of the message was deleted because HTML :( a href="&controller=home,&action=index" input name="&model.Surname" type="&string" a href="&routename=myway,&direction=up"
In short, tags attributes does not appear magically, I can use my custom tag-attributes; what will be changed are some attribute values.
btw good new for asp.net
Prefix, please.
How frustrating would it be for someone to put an attribute on an element expecting it to show up in the rendered HTML, for it only to trigger a "tag helper" and produce wildly unexpected behavior? Language design is all about finding a balance between convenience and clarity - and not having a prefix here, I believe, is quite the opposite of clarity for minimal amounts of convenience.
I don't believe the "but it looks more like HTML so people would be more comfortable with it" argument in the slightest. It isn't HTML. People shouldn't, and won't, be automatically aware of a Razor specific feature if they only know straight HTML. When they do become aware of it as a feature, it should be because "oh, hey - that's odd... what is that 'asp:' prefix all about? Must be something that ASP.NET does. Let's look at the docs." instead of "what the...?! Why is my HTML magically turning into something else?!"
A prefix would be less confusing for a person who knows HTML, but not Razor.
As far as a solution that only works in Visual Studio? Although that would make things clear, it would only affect people using VS. Considering one of ASP.NET vNext's major aspects is all about pushing ASP.NET into the cross platform market; this would, symbolically, be a bad move. In addition, not everyone (especially designers, sometimes) use VS to edit view files.
Finally: a prefix would actually make the experience in Visual Studio better. Now you would be able to get an autocomplete popup that only included tag helpers when you started typing a prefix - instead of getting all elements in addition.
Prefixes would also solve naming collisions.
I wonder what would happen if the W3C decides to add an action or controller ... attribute to some html tags ... Would I have to change my old code if I want to use these new features? Would I have to prefix them with html: ... Would I even be able to use these new features without your proposed "extension" ... Looks nice but doesn't feel right to me! I'd prefer a namespace prefix - that's what they are for!
@HaraldOnline This is why I suggest that this follows the custom-element spec.
+1 for prefixes, e.g. aspnet-bla or at least aspnet:bla.
Don't break W3C standards!. Please. It's late 2014 outside.
Fow those who appose. Are you crazy? Want yet another IE6 way of doing things?
What about this one (from Damian Edwards sample):
<input for="UserName" class="form-control" />
which afaiu is the taghelpers replacement for this
@Html.TextBoxFor(m => m.UserName, new { @class = "form-control" })
So I'm guessing the taghelper will add a value="@m.UserName" to the input tag above. But no one can tell just by looking at the syntax. A runat="server" would be helpful there, or perhaps add a @ somewhere?
<@input for="UserName" class="form-control">