We don’t allow questions seeking recommendations for software libraries, tutorials, tools, books, or other off-site resources. You can edit the question so it can be answered with facts and citations.
Closed 3 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(1)
这个特殊的功能并没有得到最好的记录,但 Webby 有部分功能,允许您编写页面片段并将它们包含在其他页面中。 创建一个名称以下划线开头的文件(例如
"_untocaesar"
),然后您可以通过执行<% render(:partial => '_untocaesar') % 包含它>
带有 ERB 过滤器。部分可以有标头来指示处理,就像普通页面一样。 因此,通过结合 ERB 和分部等模板语言,您应该能够为您的网站提供非常干净的分解。
这不是一般的 HTML 概念,因为 HTML 实际上只是静态页面,因此如果没有预处理器,您就无法做到这一点。 这通常是由您正在使用的框架处理的。 瓷砖是其中之一,韦比是另一个。 它到底如何工作在某种程度上取决于框架本身。
This particular feature isn't the best documented, but Webby has partials that allow you to write snippets of pages and include them in other pages. Create a file whose name begins with an underscore (say,
"_untocaesar"
), and then you can include it by doing<% render(:partial => '_untocaesar') %>
with an ERB filter.Partials can have headers to indicate processing just like normal pages can, too. So by combining a templating language like ERB and partials, you should be able to have a pretty clean factoring for your site.
This isn't a general HTML concept since HTML is really just static pages, so you can't do this without a preprocessor. It's something usually handled by the framework you are using. Tiles is one, Webby is another. Exactly how it works depends to some degree on the framework itself.