在 haml 中插入文本块

发布于 2024-09-16 10:46:51 字数 272 浏览 16 评论 0原文

在我的 Jekyll 博客中,我使用 include 标签将文件的内容放入文档中。但是,如果我尝试使用基于 HAML 的文档执行此操作,则所包含文本的缩进是错误的。 :preserve 不起作用,因为它需要缩进。有没有一种方法可以在不依赖缩进的情况下指定文本块?

%html
  %body
    - preserve do
<strong>included text from file</strong>
    - end

In my Jekyll blog I use the include tag to put the contents of a file into the document. However if I attempt to do this with a HAML based document the indentation of the included text is wrong. :preserve does not work because it requires indentation. Is there a way to specify a block of text without depending on indentation?

%html
  %body
    - preserve do
<strong>included text from file</strong>
    - end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风吹短裙飘 2024-09-23 10:46:51

看来当前版本的 Haml :text 过滤器已被删除。现在您可以使用 :plain 过滤器。不会对该块内的文本执行任何处理。您可以在此处粘贴多行文本块或 HTML 代码。 HTML 将在未转义的页面上显示。

:plain
  Some text <b>or HTML</b>.

It seems that in current version of Haml :text filter was removed. Now you can use :plain filter. No processing is performed for the text inside this block. You can paste multiline blocks of text or HTML code there. HTML will appear on the page unescaped.

:plain
  Some text <b>or HTML</b>.
过潦 2024-09-23 10:46:51

对于文本,请使用过滤器:

:text
  some text
:erb
  <%= render :partial ... %>

http://haml-lang.com/文档/yardoc/file.HAML_REFERENCE.html#filters

For text, use filters:

:text
  some text
:erb
  <%= render :partial ... %>

http://haml-lang.com/docs/yardoc/file.HAML_REFERENCE.html#filters

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文