如何使用Ruby帮助方法ERB将HTML转换为Slim语法

时间:2022-11-22 22:57:30

Trying to convert some HTML code in a template to Slim syntax. The original code uses a Ruby helper method (in Rails) to dynamically determine the class of the li element.

尝试将模板中的某些HTML代码转换为Slim语法。原始代码使用Ruby辅助方法(在Rails中)动态确定li元素的类。

Here is the original code in HTML:

这是HTML中的原始代码:

<li class="<%= is_active_controller('dashboards') %>">

The online converter gives:

在线转换器给出:

| <li class="
= is_active_controller('dashboards')
| ">

This not only is ugly and clunky--it doesn't work.

这不仅是丑陋和笨重 - 它不起作用。

I've tried various options without success. Such as:

我尝试过各种各样的选择而没有成功。如:

li class=is_active_controller('dashboards')

...as well as several other variations without success.

...以及其他一些变化没有成功。

1 个解决方案

#1


0  

li class=(is_active_controller('dashboards'))

#1


0  

li class=(is_active_controller('dashboards'))