diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-24 21:46:31 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-24 21:46:31 +0300 |
| commit | f0154c2df57aae016f720122c8208fc4a1082495 (patch) | |
| tree | d14856b669eba6714fe1f35a65b1223371c87bdd /src/lib/stats-render.source.sh | |
| parent | a79e7d77cc6717f6c5bfaaefa5361f396c322de3 (diff) | |
Unify escape/date helper API; fix current_date_text caching
Make the template.source.sh escape/date helper family follow one
consistent shape: each escaper now has a nameref <name>_to form (hot
path, writes a named variable) plus a thin printf wrapper <name> that
delegates to it. The leading "_" now exclusively marks private
helpers; the public escape API (called from sibling modules) is
unprefixed.
- current_date_text now delegates to current_date_text_to so both
forms share the SHURIKEN_CURRENT_DATE_TEXT cache; the printf form no
longer silently re-execs `date` on every direct call. Output
unchanged.
- Drop the misleading "_" prefix on the public escape API and update
all callers: _html_escape->html_escape, _css_string_escape->
css_string_escape, _json_string->json_string, _json_bool->json_bool,
_json_string_escape->json_string_escape.
- Add the missing JSON nameref forms: json_string_escape_to,
json_string_to, json_bool_to (printf wrappers delegate to them).
- Add tests: JSON printf-vs-nameref parity and a current_date_text
caching + nameref-parity check.
No escaping/encoding or date output changes -- API-shape/perf only.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Diffstat (limited to 'src/lib/stats-render.source.sh')
| -rw-r--r-- | src/lib/stats-render.source.sh | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/lib/stats-render.source.sh b/src/lib/stats-render.source.sh index 5431d51..b9bc067 100644 --- a/src/lib/stats-render.source.sh +++ b/src/lib/stats-render.source.sh @@ -84,7 +84,7 @@ _stats_section_open() { if [ -n "$list_class" ]; then ul_class+=" $list_class" fi - heading_html=$(_html_escape "$heading") + heading_html=$(html_escape "$heading") printf '<section class="stats-section">\n' printf '<h2>%s</h2>\n' "$heading_html" printf '<ul class="%s">\n' "$ul_class" @@ -156,7 +156,7 @@ _stats_render_ordered_section() { if [ -z "${counts_ref[$bucket]:-}" ]; then continue fi - row_html=$(_stats_filter_link "$prefix" "$bucket" "$(_html_escape "$bucket")") + row_html=$(_stats_filter_link "$prefix" "$bucket" "$(html_escape "$bucket")") _stats_bar_row "$row_html" "${counts_ref[$bucket]}" "$total" "$max" done _stats_section_close @@ -183,7 +183,7 @@ _stats_render_ranked_section() { max=$(_stats_max_count "$array_name") _stats_section_open "$heading" "$list_class" while IFS= read -r key; do - row_html=$(_stats_filter_link "$prefix" "$key" "$(_html_escape "$key")") + row_html=$(_stats_filter_link "$prefix" "$key" "$(html_escape "$key")") _stats_bar_row "$row_html" "${counts_ref[$key]}" "$total" "$max" done < <(_stats_keys_by_count_desc "$array_name") _stats_section_close |
