Class: Scribo::ContentRenderService
- Inherits:
-
ApplicationService
- Object
- ApplicationService
- Scribo::ContentRenderService
- Defined in:
- app/services/scribo/content_render_service.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#initialize(content, context, options = {}) ⇒ ContentRenderService
constructor
A new instance of ContentRenderService.
- #perform ⇒ Object
Methods inherited from ApplicationService
Constructor Details
#initialize(content, context, options = {}) ⇒ ContentRenderService
Returns a new instance of ContentRenderService.
9 10 11 12 13 14 15 16 |
# File 'app/services/scribo/content_render_service.rb', line 9 def initialize(content, context, = {}) super() @content = content @context = context @options = @assigns = nil @registers = nil end |
Instance Attribute Details
#content ⇒ Object (readonly)
Returns the value of attribute content.
7 8 9 |
# File 'app/services/scribo/content_render_service.rb', line 7 def content @content end |
#context ⇒ Object (readonly)
Returns the value of attribute context.
7 8 9 |
# File 'app/services/scribo/content_render_service.rb', line 7 def context @context end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'app/services/scribo/content_render_service.rb', line 7 def @options end |
Instance Method Details
#perform ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'app/services/scribo/content_render_service.rb', line 18 def perform if content.kind == 'asset' render_asset else layout = [:layout] == false ? nil : content.layout # FIXME: Though this works for layout, we need to be able to merge all properties with defaults # Luckily this is mostly used for layouts if [:site] layout_name = [:site].defaults_for(content)['layout'] layout ||= [:site].contents.layout(layout_name).first if layout_name end render_liquidum([:data] || content.data, layout) end end |