{%- macro sanitise_trailing_slash(s) -%}{{ s.rstrip("/") }}{%- endmacro -%}

{%- macro determine_page_view_link() -%}
  {%- if theme_source_view_link -%}
    {{ theme_source_view_link.format(filename=pagename+page_source_suffix) }}
  {%- elif theme_source_repository -%}
    {#- First, sanitise the trailing slashes. -#}
    {%- set repo = sanitise_trailing_slash(theme_source_repository) -%}
    {%- set branch = theme_source_branch -%}
    {%- set subdirectory = sanitise_trailing_slash(theme_source_directory)