Podium.Placeholder (Podium v0.3.0)

Copy Markdown View Source

Layout placeholder management for slide content.

Each slide layout defines named placeholder positions (title, subtitle, content, etc.) that can be filled with text or pictures. This module handles creating placeholder structs and rendering their XML.

Placeholders can be addressed two ways. The bundled template's layouts have names (:title, :content, ...) listed in placeholders_for/1. Any template's layouts can be addressed by the {type, idx} pair that Podium.Template.inspect/1 reports for each placeholder.

Summary

Functions

Creates a text placeholder shape addressed by the layout placeholder's own {type, idx}, as reported by Podium.Template.inspect/1.

Creates a text placeholder shape for the given placeholder name and text.

Creates a date placeholder at the idx the layout uses for its date.

Creates a footer placeholder at the idx the layout uses for its footer.

Creates a picture placeholder struct addressed by the layout placeholder's own {type, idx}.

Creates a picture placeholder struct (kind: :picture).

Creates a slide number placeholder at the idx the layout uses for its slide number.

Normalises a placeholder reference to {type, idx} with the OOXML attribute defaults filled in: a missing type is "obj" and a missing idx is 0.

Returns the known placeholder definitions for a layout.

Generates the XML for a placeholder shape. Dispatches based on the :kind field.

Types

t()

@type t() :: %Podium.Placeholder{
  field_text: String.t() | nil,
  idx: non_neg_integer() | nil,
  image_rid: String.t() | nil,
  kind: :text | :picture | :footer | :date | :slide_number | nil,
  paragraphs: [map()] | nil,
  type: String.t() | nil
}

Functions

new(arg, text)

@spec new(
  {String.t(), non_neg_integer()},
  Podium.rich_text()
) :: t()

Creates a text placeholder shape addressed by the layout placeholder's own {type, idx}, as reported by Podium.Template.inspect/1.

new(layout, name, text)

@spec new(atom(), atom(), Podium.rich_text()) :: t()

Creates a text placeholder shape for the given placeholder name and text.

new_date(text, idx)

@spec new_date(String.t(), non_neg_integer()) :: t()

Creates a date placeholder at the idx the layout uses for its date.

new_footer(text, idx)

@spec new_footer(String.t(), non_neg_integer()) :: t()

Creates a footer placeholder at the idx the layout uses for its footer.

new_picture(arg)

@spec new_picture({String.t(), non_neg_integer()}) :: t()

Creates a picture placeholder struct addressed by the layout placeholder's own {type, idx}.

The type is the layout placeholder's, not "pic": PowerPoint leaves a content placeholder's p:ph alone when a picture is inserted into it, so a picture in a content placeholder is {"obj", idx}.

new_picture(layout, name)

@spec new_picture(atom(), atom()) :: t()

Creates a picture placeholder struct (kind: :picture).

new_slide_number(idx)

@spec new_slide_number(non_neg_integer()) :: t()

Creates a slide number placeholder at the idx the layout uses for its slide number.

normalize_ref(arg1)

@spec normalize_ref(Podium.Template.ref()) :: {String.t(), non_neg_integer()}

Normalises a placeholder reference to {type, idx} with the OOXML attribute defaults filled in: a missing type is "obj" and a missing idx is 0.

Accepts a {type, idx} tuple, a %Podium.Placeholder{}, or any map with :type and :idx keys, such as a definition from placeholders_for/1.

placeholders_for(layout)

@spec placeholders_for(atom()) :: %{required(atom()) => map()}

Returns the known placeholder definitions for a layout.

to_xml(ph, hyperlink_rids \\ %{})

@spec to_xml(t(), map()) :: String.t()

Generates the XML for a placeholder shape. Dispatches based on the :kind field.