class TemplateScope
Provides the scope for XRB template rendering.
Templates access slide content via self.section(name) and slide metadata via self.slide.
Definitions
def initialize(slide)
Initialize a new template scope for the given slide.
Signature
-
parameter
slideSlide The slide being rendered.
Implementation
def initialize(slide)
@slide = slide
end
attr :slide
Signature
-
attribute
Slide The slide being rendered.
def content
The content sections of the slide.
Signature
-
returns
Hash(String, String) Sections keyed by heading name.
Implementation
def content
@slide.content
end
def section?(name)
Whether the named content section exists and has content.
Signature
-
parameter
nameString The section name (derived from the Markdown heading).
-
returns
Boolean
Implementation
def section?(name)
fragment = @slide.content[name]
fragment && !fragment.empty?
end
def section(name)
Get a named content section as raw HTML markup.
Signature
-
parameter
nameString The section name (derived from the Markdown heading).
-
returns
XRB::MarkupString The rendered HTML content, safe for embedding.
Implementation
def section(name)
XRB::MarkupString.raw(@slide.content[name]&.to_html || "")
end