将HTML助手迁移到ASP.NET Core [英] Migrate html helpers to ASP.NET Core

查看:68
本文介绍了将HTML助手迁移到ASP.NET Core的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将一个项目转换为ASP.NET Core.我需要迁移许多可重复使用的html helper,但是html helper在Core中不存在.

I'm converting a project to ASP.NET Core. I need to migrate lots of reusable html helpers, but html helpers do not exist in Core.

有些复杂,有些简单.这是一个非常简单的示例:

Some are complex, some simple. Here's a extremely simple example:

@helper EditIcon()
{
    <i class="glyphicon glyphicon-pencil"></i>
}

请注意,这仅是示例.

Point正在写一个标签助手,因为它是巨大的过大杀伤力.局部变量也是如此.视图组件相同.

Point is writing a tag helper for that is gigantic overkill. Same for partials. Same for view components.

我们正在谈论Razor的一些片段.我最好的选择是什么?

We're talking about a little snippet of Razor. What is my best option?

推荐答案

因此,似乎只有三个选项:

So, seems there are only three options:

  • tag helpers
  • partials
  • view components

因此,没有简单的方法来迁移Razor片段,而不会跳过箍.

So no simple way to migrate Razor snippets, without jumping through hoops.

编辑

所以看起来像 html帮助器

So looks like html helpers are available after all. They just haven't been properly documented!

这篇关于将HTML助手迁移到ASP.NET Core的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆