B.I*_*.I. 6 templates ruby-on-rails slim-lang
我无法理解基本的Slim语法.
第一个问题,如何进入换行(换行符)?
第二个请求,请你重写下面的片段,我怀疑我没有这么简单的方法吗?
- provide(:title, @course.title)
.row
aside.span4
section
h1 = @course.title.capitalize
=> link_to t('ui.edit'), edit_course_path(@course)
'|
=> link_to t('ui.back'), courses_path
p
b #{t('activerecord.attributes.subject.title')}:
| #{@course.subject.title}
p
b #{t('activerecord.attributes.student_level.title')}:
| #{@course.student_level.title}
h4 #{t('activerecord.attributes.course.objectives')}
= @course.objectives
Run Code Online (Sandbox Code Playgroud)
这是它的输出:
tahrirlash(编辑)| orqaga
Predmet nomi:英语5-7岁
O'quvchi darajasi:初学者
目标b
对于新行,您应该只使用br:
h1 Line1 content
br
h1 Line2 content
Run Code Online (Sandbox Code Playgroud)
关于上面提到的代码,它可以像这样重写:
-provide(:title,@course.title)
.row
aside.span4
section
h1 = @course.title.capitalize
= link_to t('ui.edit'), edit_course_path(@course)
'|
= link_to t('ui.back'), courses_path
p
b = t('activerecord.attributes.subject.title')
|:
= @course.subject.title
p
b = t('activerecord.attributes.student_level.title')
|:
= @course.student_level.title
h4 = t('activerecord.attributes.course.objectives')
= @course.objectives
Run Code Online (Sandbox Code Playgroud)
要将br标签插入 slim 中的某个标签中:
示例 1. Slim 模板:
h1
| Hello
br
| world
Run Code Online (Sandbox Code Playgroud)
它将生成 html:
<h1>Hello<br>world</h1>
Run Code Online (Sandbox Code Playgroud)
示例 2.用于显示表单的 slim 模板片段:
p
= f.label :title
br
= f.text_field :title
Run Code Online (Sandbox Code Playgroud)
它将生成 html:
<p>
<label for="question_title">Title</label><br>
<input name="question[title]" id="question_title" type="text">
</p>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12879 次 |
| 最近记录: |