aspnetcore icon indicating copy to clipboard operation
aspnetcore copied to clipboard

Support creating Tag Helpers using CSHTML files

Open DamianEdwards opened this issue 10 years ago • 8 comments

Just an initial idea:

RepeatTagHelper.cshtml

@tagHelper "repeat"

@class {
    [HtmlAttributeName("repeat")]
    public int Repeat { get; set; }
}

@{
    output.TagName = null;
}

@for (var i = 0; i < Repeat; i++) {
    @await output.GetChildContentAsync(useCachedValue: false)
}

DamianEdwards avatar Aug 19 '16 17:08 DamianEdwards

public int Repeat { get; set; }?

pranavkm avatar Aug 19 '16 17:08 pranavkm

Doh, typo

DamianEdwards avatar Aug 19 '16 17:08 DamianEdwards

This is a very cool one, perhaps it's very handy if we support it too in the "Razor Pages", because it's kind of Razor Helpers that we know and love

hishamco avatar Aug 20 '16 01:08 hishamco

Yep, this would of course work with the pages stuff too.

DamianEdwards avatar Aug 20 '16 01:08 DamianEdwards

Can we use @functions instead of @class because the block already allow us to declare properties

hishamco avatar Aug 20 '16 01:08 hishamco

It's too thin of a veneer, IMO. So for people that know tag helpers, why not just code in C#. For those that don't already know how tag helpers work, there's too much magic here.

brockallen avatar Aug 20 '16 02:08 brockallen

Wouldn't that essentially be the same functionality as a ViewComponent?

82dsoldier avatar Sep 16 '16 10:09 82dsoldier

Moving to the backlog, this is not planned for 2.0.0-preview1.

rynowak avatar Apr 10 '17 20:04 rynowak