Skip to content

Easier template format #706

@OnceUponALoop

Description

@OnceUponALoop

(not a bug)
I wanted to wrap my head around the template and I couldn't do it without getting proper syntax highlighting and indentation so I can follow along.

It took a little while but I put this together to match the v24.8.0 template, thought i'd pass it along.
Let me know if you want a PR.

Would you be open to an examples directory to hold different usage scenarios for reference? I can put together my use case, template, and config along with a small readme.

{%- set newline = "\n" %}
{%- if render_title %}
   {%- if versiondata.name %}
       {{- "# " }}{{ versiondata.name }} {{ versiondata.version }} ({{ versiondata.date }}){{ newline * 2 }}
   {%- else %}
       {{- "# " }}{{ versiondata.version }} ({{ versiondata.date }}){{ newline * 2 }}
   {%- endif %}
{%- endif %}
{%- for section, _ in sections.items() %}
   {%- if section %}
       {{- "## " }}{{section}}{{ newline * 2 }}
   {%- endif %}

   {%- if sections[section] %}
       {%- for category, val in definitions.items() if category in sections[section] %}
           {{- "### " }}{{ definitions[category]['name'] }}
           {{- newline * 2 }}

           {%- for text, values in sections[section][category].items() %}
               {{- "- " }}{{ text }}
               {%- if values %}
                   {%- if "\n  - " in text or '\n  * ' in text %}
                       {{- newline * 2 }}
                       {{- "  (" }}
                   {%- else %}
                       {%- if text %} ({% endif %}
                   {%- endif -%}
                   {%- for issue in values %}
                       {{- issue.split(": ", 1)[0] }}{% if not loop.last %}, {% endif %}
                   {%- endfor %}
                   {%- if text %}){% endif %}
                   {{- newline * 2 }}
               {%- else %}
                   {{- newline * 2 }}
               {%- endif %}
           {%- endfor %}

           {%- if issues_by_category[section][category] and "]: " in issues_by_category[section][category][0] %}
               {%- for issue in issues_by_category[section][category] %}
                   {{- issue }}
               {%- endfor %}
               {{- newline * 2 }}
           {%- endif %}
           {%- if sections[section][category]|length == 0 %}
               {{- "No significant changes." }}
               {{- newline * 2 }}
           {%- else %}
           {%- endif %}
       {%- endfor %}
   {%- else %}
       {{- "No significant changes." }}
       {{- newline * 2 }}
   {%- endif %}
{%- endfor %}
{#
This comment adds one more newline at the end of the rendered newsfile content.
In this way the there are 2 newlines between the latest release and the previous release content.
#}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions