Class: NicePartials::Partial::Content
- Inherits:
-
Object
- Object
- NicePartials::Partial::Content
- Defined in:
- lib/nice_partials/partial/content.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Options
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Contains options passed to a partial:.
Instance Method Summary collapse
-
#initialize(view_context, content = nil) ⇒ Content
constructor
A new instance of Content.
- #write ⇒ Object
- #write?(content = nil, **new_options, &block) ⇒ Boolean
Constructor Details
#initialize(view_context, content = nil) ⇒ Content
Returns a new instance of Content.
12 13 14 15 |
# File 'lib/nice_partials/partial/content.rb', line 12 def initialize(view_context, content = nil) @view_context, = view_context, Options.new(view_context) @content = ActiveSupport::SafeBuffer.new and concat content end |
Instance Attribute Details
#options ⇒ Object (readonly)
Contains options passed to a partial:
<% partial.title class: "post-title" %> # partial.title.options # => { class: "post-title" }
# Automatically runs `tag.attributes` when `to_s` is called, e.g.:
<h1 <% partial.title.options %>> # => <h1 class="post-title">
24 25 26 |
# File 'lib/nice_partials/partial/content.rb', line 24 def end |
Instance Method Details
#write ⇒ Object
31 32 33 34 |
# File 'lib/nice_partials/partial/content.rb', line 31 def write(...) write?(...) self end |
#write?(content = nil, **new_options, &block) ⇒ Boolean
26 27 28 29 |
# File 'lib/nice_partials/partial/content.rb', line 26 def write?(content = nil, **, &block) .merge! append content or capture block end |