slim-lang 的 if-else 嵌套代码 [英] slim-lang's if-else nested code
本文介绍了slim-lang 的 if-else 嵌套代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想根据slim-lang中的条件为HTML的一部分分配一个css类
I want to assign a css class to a part of HTML based on condition in slim-lang
我正在做以下事情
- if current_user
.title
- else
.title_else
现在如何编写应嵌套在上述类之一中的 HTML?我需要在 if
条件和 else
条件中编写 HTML 吗?
Now how can i write the HTML that should be nested in the one of the class above? Do i need to write HTML in the both if
condition and else
condition ?
原因是应该嵌套在上述类之一中的 HTML 应该进一步向右.但如果我打算进一步正确,它包括在其他条件下.我现在应该如何处理?
The reason is that the HTML that should be nested in one of the above class should be further intended rightwards. But if i intend it further right, it is including under else condition. How shoule i approach this now ?
推荐答案
这是一个单行:
.thing class=(current_user ? 'large-menu' : 'medium-menu')
h4 Same content, different class
这篇关于slim-lang 的 if-else 嵌套代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文