module Roda::RodaPlugins::ContentFor::InstanceMethods

  1. lib/roda/plugins/content_for.rb

Methods

Public Instance

  1. content_for

Public Instance methods

content_for(key, value=nil, &block)

If called with a block, store content enclosed by block under the given key. If called without a block, retrieve stored content with the given key, or return nil if there is no content stored with that key.

[show source]
   # File lib/roda/plugins/content_for.rb
75 def content_for(key, value=nil, &block)
76   append = opts[:append_content_for]
77 
78   if block || value
79     if block
80       value = capture_erb(&block)
81     end
82 
83     @_content_for ||= {}
84 
85     if append
86       (@_content_for[key] ||= []) << value
87     else
88       @_content_for[key] = value
89     end
90   elsif @_content_for && (value = @_content_for[key])
91     if append
92       value = value.join
93     end
94 
95     value
96   end
97 end