Class: Presently::TemplateScope

Inherits:
Object
  • Object
show all
Defined in:
lib/presently/slide_renderer.rb

Overview

Provides the scope for XRB template rendering.

Templates access slide content via ‘self.section(name)` and slide metadata via `self.slide`.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(slide) ⇒ TemplateScope

Initialize a new template scope for the given slide.



65
66
67
# File 'lib/presently/slide_renderer.rb', line 65

def initialize(slide)
	@slide = slide
end

Instance Attribute Details

#slideObject (readonly)

Returns the value of attribute slide.



70
71
72
# File 'lib/presently/slide_renderer.rb', line 70

def slide
  @slide
end

Instance Method Details

#contentObject

The content sections of the slide.



74
75
76
# File 'lib/presently/slide_renderer.rb', line 74

def content
	@slide.content
end

#section(name) ⇒ Object

Get a named content section as raw HTML markup.



89
90
91
# File 'lib/presently/slide_renderer.rb', line 89

def section(name)
	XRB::MarkupString.raw(@slide.content[name]&.to_html || "")
end

#section?(name) ⇒ Boolean

Whether the named content section exists and has content.

Returns:

  • (Boolean)


81
82
83
84
# File 'lib/presently/slide_renderer.rb', line 81

def section?(name)
	fragment = @slide.content[name]
	fragment && !fragment.empty?
end

#The slide being rendered.=(slidebeingrendered. = (value)) ⇒ Object



70
# File 'lib/presently/slide_renderer.rb', line 70

attr :slide