Module: Sevgi::Graphics::Mixtures::Render

Defined in:
lib/sevgi/graphics/mixtures/render.rb

Overview

DSL helpers for rendering SVG documents and children.

Instance Method Summary collapse

Instance Method Details

#Render(**options) ⇒ String

Renders this element as SVG source. Elements with inline text content may also contain inline children such as tspan; the renderer keeps those descendants in the same text line. Whitespace inside content objects is preserved as given, and encoded content is XML-escaped unless a verbatim content object is used. SVG style elements use block content; same-named elements under a foreign default namespace retain ordinary inline text formatting.

Parameters:

  • options (Hash)

    renderer options

Returns:

  • (String)

    SVG source

Raises:

  • (Sevgi::ArgumentError)

    when options, preambles, names, attributes, or content are invalid XML



361
# File 'lib/sevgi/graphics/mixtures/render.rb', line 361

def Render(**) = Renderer.(self, **)

#RenderChildren(separator = "\n\n") ⇒ String

Renders only this element's children. Child render output omits document preambles and preserves each child's text whitespace and inline mixed-content formatting.

Parameters:

  • separator (String) (defaults to: "\n\n")

    separator between child documents

Returns:

  • (String)

    rendered child fragments

Raises:

  • (Sevgi::ArgumentError)

    when separator or rendered child data is not valid XML text



369
370
371
372
373
374
# File 'lib/sevgi/graphics/mixtures/render.rb', line 369

def RenderChildren(separator = "\n\n")
  ArgumentError.("SVG fragment separator must be a String") unless separator.is_a?(::String)

  separator = XML.text(separator, context: "SVG fragment separator")
  children.map { Renderer.fragment(it) }.join(separator)
end