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.



54
55
56
# File 'lib/presently/slide_renderer.rb', line 54

def initialize(slide)
	@slide = slide
end

Instance Attribute Details

#slideObject (readonly)

Returns the value of attribute slide.



59
60
61
# File 'lib/presently/slide_renderer.rb', line 59

def slide
  @slide
end

Instance Method Details

#contentObject

The content sections of the slide.



63
64
65
# File 'lib/presently/slide_renderer.rb', line 63

def content
	@slide.content
end

#section(name) ⇒ Object

Get a named content section as raw HTML markup.



78
79
80
# File 'lib/presently/slide_renderer.rb', line 78

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)


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

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

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



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

attr :slide