在HAML中对称清洁的扩展(按线单行)阵列?

发布于 2025-01-22 12:21:09 字数 683 浏览 1 评论 0原文

我试图弄清楚是否有某种方法可以在视觉上“清洁”且易于分类,以便每行带有一个数组项目,只有一个数组项目(加上逗号)。

- conditions = [feature_on,
  job_has_started,
  user_can_request,
  no_current_request,
  job_reappointable,
  stopping_soon,]

如果我想重新排序条件(代表用于确定是否显示表格的lambdas)以将最快的条件放在第一个(或交替地放置最常见的条件)状况。我还必须讨厌开口和关闭的括号和其他东西。这不是我的优雅想法。我想要一些更接近这一点的东西:

- conditions = [
  feature_on,
  job_has_started,
  user_can_request,
  no_current_request,
  job_reappointable,
  stopping_soon,
  ]

但是我还没有找到任何方法来获得HAML来允许这一点。 \在第一行的末尾无法解决问题。 Haml自己的“ |”也不是在HAML的其他情况下类似地使用的。我不是100%确定是否可能。但是我敢肯定,还有其他人试图与HAML实现相似的目的。我该怎么做?

如果目前不可能使用开箱即用的HAML,那么修补HAML允许这一点会有多大的困难?

I'm trying to figure out if there's some way to make the following code both visually "clean" and also easily sortable so each line with an array item has one array item and only one array item (plus the comma).

- conditions = [feature_on,
  job_has_started,
  user_can_request,
  no_current_request,
  job_reappointable,
  stopping_soon,]

If I want to reorder the conditions (which represent lambdas used to determine whether a form is shown or not) to put the fastest conditions to compute first (or alternately putting the conditions that are most often false) I can't necessarily simply reorder the conditions. I have to also muck about with the opening and closing brackets and other things. This is not my idea of elegance. I would like something much closer to this:

- conditions = [
  feature_on,
  job_has_started,
  user_can_request,
  no_current_request,
  job_reappointable,
  stopping_soon,
  ]

But I have not found any way to get HAML to allow this. \ at the end of the first line does not solve the problem. Neither does HAML's own '|', which is used similarly in other situations in HAML. I'm not 100% sure whether it is possible. But I'm sure there are others who have tried to achieve similar ends with HAML. How can I do it?

If it's not currently possible with out-of-the-box HAML, how hard would it be to patch HAML to allow this?

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

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

发布评论

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

评论(1

请帮我爱他 2025-01-29 12:21:09

使用:Ruby过滤器 htttps:// haml.info/docs/yardoc/file.reference.html#ruby-filter

:ruby
  conditions = [
    feature_on,
    user_can_request,
    job_has_started,
    no_current_request,
    job_reappointable,
    stopping_soon,
  ]

Use a :ruby filter https://haml.info/docs/yardoc/file.REFERENCE.html#ruby-filter.

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