使用 HAML 进行 Rails HTTP 流式传输

发布于 2024-12-05 16:15:24 字数 446 浏览 4 评论 0原文

在 Rails 中对 HAML 项目使用 HTTP 流似乎存在问题。如果我使用 ERB 的话效果会很好。显然,我不是唯一一个这个问题。

它不适用于将 stream 放置在控制器顶部,或使用 render :stream =>; true 在操作中。

如何让 HAML 和 HTTP 流能够很好地协同工作?

更新:我在 gem 页面上提出了一个问题,此处。

There appears to be an issue with using HTTP streaming with HAML projects in rails. It works perfectly if I use ERB instead. Apparently, I'm not the only one with this problem.

It doesn't work with placing stream at the top of the controller, or with using render :stream => true in the action.

How can I get HAML and HTTP streaming to play nicely together?

Update: I've opened an issue on the gem's page, here.

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

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

发布评论

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

评论(2

一花一树开 2024-12-12 16:15:24

HAML 尚不支持此功能(来源):

HTTP 流是一种需要大量资源的东西
对核心 Haml 引擎的一组修改。这只是中等程度
即使在基本情况下也很难让它工作,但是当你考虑到
像吃空白操作符之类的东西它会得到更多
困难。

这在理论上并不是我反对的,但也不是
考虑到困难,这是我优先考虑的事情
实施它。

This is not yet supported by HAML (source):

HTTP streaming is the sort of thing that would require a substantial
set of modifications to the core Haml engine. It's only moderately
tricky to get it working even in basic cases, but when you factor in
things like the whitespace-eating operators it gets much more
difficult.

This isn't something I'm opposed to in theory, but it's also not
something that's high on my priority list given the difficulty of
implementing it.

记忆之渊 2024-12-12 16:15:24

Haml 的内部结构是这样的,它确实在运行时写入缓冲区。然而,Rails 传统上为模板语言提供的“标准”API 是相当简单的进出调用。我不认为 Haml 目前有“流媒体支持”,但它更多的是一个 API 问题而不是其他任何问题。

我很好奇 Rails 如何插入 ERB 来做到这一点。

The internals of Haml are such that it is indeed writing out to a buffer as it goes along. However, the "standard" API that Rails has traditionally provided for templating languages is a fairly straightforward in-and-out call. I don't think Haml does currently have "streaming support", but its simply more of an API issue than anything else.

I'm curious as to how Rails is plugging into ERB to do this.

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