Update on TagHelpers with Taylor Mullen

Sign in to queue

Description

Join your guide Cory Fowler as he talks to the product teams in Redmond as well as the web community.

This week Cory is joined by Taylor Mullen from the ASP.NET Team. Taylor is coming on the show to do an update on the previous Tag Helper show. This show revisits some of the concepts that have changed in tag helpers with the help of your feedback, as well as goes into a deeper dive on some specific Tag Helper scenarios.

Note: This show was recorded a while back and got lost in the queue, please review the comments for changes since the recording.

 Show Links

Embed

Download

Download this episode

The Discussion

  • User profile image
    Troussedeto​ilette

    Thank you for sharing this tuto. Video is a great solution to help people ! 

  • User profile image
    cecilphillip

    the packages in the project.json in this video are referencing beta4 which is 2 betas old based on the current date. 

    How much of this is still relevant? This projects has a tremendous about of change still going on

  • User profile image
    cecilphillip

    Wouldn't it make sense to merge _ViewStart and _GlobalImports?

  • User profile image
    NTaylor​Mullen

    Hey @scyonx. I've compiled a list of things that have changed (small list). We'll be sure to add them to the show notes.

    Here's the list I have:

    • _GlobalImport.cshtml renamed to _ViewImports.cshtml
    • Dependency Injection can only be done via constructor now.

    Feel free to let me know if I missed something.

  • User profile image
    Jesper

    ActivateAttribute is used and has been removed: https://github.com/aspnet/Announcements/issues/28

    I like that the changes are happening now rather than after release, but it also means that these kinds of shows, especially the ones meant to "set the record straight", must be posted while they're still fresh.

  • User profile image
    RickAnderson​MS

     @scyonx - Most of the video is relevant but as you pointed out there are changes.

    _GlobalImports is now _ViewImports.cshtml. You can't move tag helpers to _ViewStart  as it's only for running code.

  • User profile image
    Janisku7

    great one :)

    I was thinking if you was also able to change bootstraps via taghelpers  on the fly like having multiple bootstrap in one webapplication

  • User profile image
    NTaylor​Mullen

    @Janisku7 you could absolutely do that. There are various ways you could approach that problem. Two that I can think of:

    1. Create your own `<bootstrap />` TagHelper element that brings in dynamic bootstrap themes.
    2. Create a TagHelper that targets `<link>` elements and detects if one is attempting to bring in bootstrap. If so, dynamically modify which bootstrap theme is brought in.
  • User profile image
    Worldlifesi​te

    Can you do a video that adds more clarity for best use scenarios between TagHelpers and ViewComponents?  There doesn't seem to be much via a search on "taghelpers vs viewcomponents".

    thanks.

  • User profile image
    NTaylor​Mullen

    Hey @Worldlifesite I'm not sure if the guidance for ViewComponents vs. TagHelpers would be hearty enough for its own video but here's the guidance I'd give:

    Use ViewComponents for application/business logic and TagHelpers as rendering utilities to bridge the gap between server and client.

  • User profile image
    Worldlifesi​te

    So how do you determine if you should create tag cloud as a TagHelper or as a ViewComponent?  ViewComponent docs use tag cloud as an example use but, it looks like its possible to also create the tag cloud as a tag <tagcloud />.

  • User profile image
    NTaylor​Mullen

    @Worldlifesite TagCloud is a veryyyyy simple sample and more or less just validates that TagHelpers and ViewComponents can do something complex. I definitely wouldn't refer to that as a strong example of what to do though :).

    If I had to specify it as either one or the other I'd say it should probably be a ViewComponent. My combined reasoning:

    1. It doesn't generate a tag (just content).
    2. It performs "business" type logic.
    3. It's not meant to be composable.
  • User profile image
    cocoland

    Thank you for this tuto !

Add Your 2 Cents