是HTML佣工值得复杂的标记使用? [英] Are HTML helpers worth using with complex markup?

查看:117
本文介绍了是HTML佣工值得复杂的标记使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要坚持用HTML辅助,或只是使用普通的HTML?

我一直在使用HTML佣工,而现在,真正使用它们享用。最近,我用CSS框架,比如 Twitter的引导开始,我发现我的标记过于复杂,使用标准的HTML佣工。

当然,我仍然可以使用 Url.Action()生成链接,有时 @ Html.TextBoxFor()或简单的形式相似,但例如,我发现了一些像 Html.ActionLink佣工()使用Html.BeginForm() 只是不削减它。

我的标记通常包含复杂的巢穴。例如,在引导我可能要添加一个图标为纽带的一部分:

 < A HREF =#>
    < I类=图标的用户>< I&GT /;
    <跨度>简单的链接< / SPAN>
&所述; / A>

这是很常见的与引导,我觉得像HTML辅助会碍事。我可以做我自己,但我的标记是完全不同的一切都完了。

假如我只用少量的HTML佣工;在需要的地方。这就提出了另一个问题:

如果我最大限度地减少HTML帮助的使用,我应该只是把它们完全和主要使用常规的HTML的一致性?


解决方案

  

如果我最大限度地减少HTML帮助的使用,我应该只是把它们
  完全和主要使用常规的HTML的一致性?


没有,总是使用HTML佣工。在复杂的锚的例子你仍然可以使用 Url.Action 助手来设置其的href 属性和硬code它的其他部分。

Should I persist with using HTML helpers, or just use plain HTML?

I've been using HTML helpers for a while now and really enjoyed using them. Recently I've started using CSS frameworks such as Twitter Bootstrap and I'm finding that my markup is too complex to use the standard HTML helpers.

Of course, I still use Url.Action() for generating links and sometimes @Html.TextBoxFor() or similar for simple forms, but, for example, I'm finding some helpers like Html.ActionLink() or Using Html.BeginForm() just don't cut it.

My markup often contains complex nests. For example, in Bootstrap I might want to add an icon as part of a link:

<a href="#">
    <i class="icon-user"></i>
    <span>Simple link</span>
</a>

This is very common with Bootstrap and I feel like HTML helpers would get in the way. I can make my own, but my markup is quite different all over.

Suppose I only use HTML helpers in small amounts; where needed. This raises another question:

If I'm minimising HTML helper usage, should I just drop them altogether and primarily use regular HTML for consistency?

解决方案

If I'm minimising HTML helper usage, should I just drop them altogether and primarily use regular HTML for consistency?

No, always use HTML helpers. In the example of complex anchors you could still use the Url.Action helper to set its href attribute and hardcode the other parts of it.

这篇关于是HTML佣工值得复杂的标记使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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