Cherry.Theme.Helpers (cherry v0.6.0)

Copy Markdown View Source

Functions available to theme templates.

Templates opt in with <% import Cherry.Theme.Helpers %> at the top — explicit, visible to theme authors, no hidden magic in the renderer.

Summary

Functions

The CV bullets for an entry: the cv: block's curated highlights win over the timeline ones (curation, not duplication — DESIGN.md §4).

Formats a date for display, e.g. January 15, 2026.

Formats a month for display, e.g. Apr 2015.

A date span: Jan 2020 — present, Jan 2020 — May 2022, or "".

Escapes text for safe interpolation into HTML.

Site-rooted href for an output-relative location — respects base_path.

URL-safe slug for a tag name.

Functions

cv_highlights(map)

@spec cv_highlights(%{
  cv: Cherry.Portfolio.Curation.t() | nil,
  highlights: [String.t()]
}) :: [
  String.t()
]

The CV bullets for an entry: the cv: block's curated highlights win over the timeline ones (curation, not duplication — DESIGN.md §4).

format_date(date)

@spec format_date(Date.t()) :: String.t()

Formats a date for display, e.g. January 15, 2026.

format_month(date)

@spec format_month(Date.t()) :: String.t()

Formats a month for display, e.g. Apr 2015.

format_range(started, ended)

@spec format_range(Date.t() | nil, Date.t() | nil) :: String.t()

A date span: Jan 2020 — present, Jan 2020 — May 2022, or "".

h(value)

@spec h(String.Chars.t()) :: String.t()

Escapes text for safe interpolation into HTML.

href(site, rel)

@spec href(Cherry.Site.t(), String.t()) :: String.t()

Site-rooted href for an output-relative location — respects base_path.

href(@site, "blog/")  #=> "/blog/" or "/repo/blog/"

tag_slug(tag)

@spec tag_slug(String.t()) :: String.t()

URL-safe slug for a tag name.