Module: Cuhaml::Contrib::ContentFor

Defined in:
lib/cuhaml/contrib/content_for.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.setup(app) ⇒ Object



6
7
8
# File 'lib/cuhaml/contrib/content_for.rb', line 6

def self.setup(app)
  app.settings[:render][:template_engine] = "haml"
end

Instance Method Details

#content_for(symbol, &block) ⇒ Object

Public: Sets a content for a given symbol

symbol - The symbol key &block - Block to be called

Examples:

<% content_for :menu do %>
  Home | Admin
<% end %>


31
32
33
# File 'lib/cuhaml/contrib/content_for.rb', line 31

def content_for(symbol, &block)
  content_blocks[symbol] << capture_haml(&block)
end

#yield_for(symbol) ⇒ Object

Public: yields a content in a view

symbol - The symbol to be searched

Examples:

<% yield_for :menu %>


17
18
19
# File 'lib/cuhaml/contrib/content_for.rb', line 17

def yield_for(symbol)
  haml_concat(content_blocks[symbol].join)
end