10
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

MiddlemanのSlimで複数のyieldを使おう

Last updated at Posted at 2013-12-01

Nodeなら鉄板のjadeですが、jadeでできる複数編集領域をSlimでも使いたい!

やりかた

  1. config.rbに設定入れる
  2. layoutのほうに == yield_content :sidebar をほりこむ
  3. 継承するほうに - content_for :sidebar do をほりこむ

config.rbに設定入れる

config.rb
Slim::Engine.set_default_options :streaming => false

参考: content_for and yield · Issue #176 · slim-template/slim

slim側

layout/layout.slim
doctype 5
html
  head
    meta charset="utf-8"
    title unko

  body class="#{page_classes}"
    #wrap
      h1 yeild 第一弾
      == yield
      h2 yeild第二弾↓
      #sidebar
        == yield_content :sidebar
.hoge
  |   ここが第一弾のブロックに置き換わる

- content_for :sidebar do
  .test ここに第二弾

これでおk!

sidebarみたいなでっかいブロック以外はヘルパー使うべし。だそうで。例えばタイトルタグみたいなのはヘルパーのほうがいいと、どこかに書いてあった。

10
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
10
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?