TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: What is with Rotten Tomatoes' HTML Source?

2 点作者 BenSchaechter超过 14 年前
1. http://rottentomatoes.com<p>2. View source

3 条评论

camtarn超过 14 年前
If you mean the crazy amount of whitespace, it may be caused by a templating system. For instance, in JSP JSTL:<p><pre><code> &#60;c:choose&#62; &#60;c:when test="${!empty article}"&#62; &#60;c:out value="${article}"/&#62; &#60;/c:when&#62; &#60;c:when test="${!empty comments}"&#62; &#60;c:out value="${article}"/&#62; &#60;/c:when&#62; &#60;/c:choose&#62; </code></pre> Each of the choose/when tags has a newline after it, so even though the tag is not output into the resulting HTML source, it causes a literal newline to be emitted. This doesn't normally matter, since HTML collapses multiple runs of whitespace into a single space.<p>However, for places where you can't have any whitespace (like the middle of a word) you can work around that by concatenating all the tags into one long line, or by strange arrangements of opening/closing angle brackets:<p><pre><code> &#60;c:choose &#62;&#60;c:when test="..." &#62;&#60;c:out ... / &#62;&#60;/c:when &#62;&#60;/c:choose&#62; </code></pre> Some webservers like Tomcat also provide the ability to strip all excess outgoing whitespace, which preserves the readability of the source files.
byoung2超过 14 年前
I use smarty, and making the template logic readable sometimes leaves extra newlines and whitespace. You can wrap {strip}{/strip} tags around it to remove it though. This is what I use to get all code in a single line as on <a href="http://www.dealspyer.com" rel="nofollow">http://www.dealspyer.com</a>
slater超过 14 年前
Only time I've seen that happen was with ColdFusion or Java-powered sites that don't strip the lines used by inline logic, eg where you see 10 empty lines, there might be an if/else snippet running. At runtime, the language runs through those parts, but keeps the space intact.