控制ASP.Net MVC中的输出压缩 [英] Controlling Output Indentation in ASP.Net MVC

查看:212
本文介绍了控制ASP.Net MVC中的输出压缩的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的同事对正确格式化和缩进的html传递给客户端浏览器非常热。这是为了让页面源代码易于被人读取。



首先,如果我的网站中有多个不同区域使用了局部视图,应该为渲染引擎自动格式化我的缩进(ala在XmlTextWriter上设置Formatting属性)?其次,我的同事创建了一些HtmlHelper扩展方法,用于写入回复。这些都需要一个CurrentIndent参数传递给它们。这对我来说是错误的。



任何人都可以帮忙吗?

解决方案

<这听起来很难维持。如果有人从HTML中移除了一个外部元素,是否有人会更新代码中的 CurrentIndent 值?现在大多数开发人员通常都会通过Firebug查看它们的HTML,它会自动使用缩进来格式化标记。



如果您确实想通过格式化过滤器后处理HTML,然后尝试 HTML Tidy的.NET端口


My colleague is extremely 'hot' on properly formatted and indented html being delivered to the client browser. This is so that the page source is easily readable by a human.

Firstly, if I have a partial view that is used in a number of different areas in my site, should the rendering engine be automatically formatting the indentations for me (ala setting the Formatting property on an XmlTextWriter)?

Secondly, my colleague has created a number of HtmlHelper extension methods for writing to the response. These all require a CurrentIndent parameter to be passed to them. This smells wrong to me.

Can anyone help with this?

解决方案

This sounds difficult to maintain. If someone removed an outer element from the HTML, would anyone bother to update the CurrentIndent values in the code? These days most developers usually view their HTML through Firebug anyway, which formats the markup automatically with indentation.

If you really want to post-process HTML through a formatting filter then try a .NET port of HTML Tidy.

这篇关于控制ASP.Net MVC中的输出压缩的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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