Dynamic setting of header markup

As the top level header in index.rst and get_started.rst depends on
cookiecutter.service the length of the header markups should also
depend on the length of cookiecutter.service.

Unfortunatelly I was not able to figure out how to include the macro
from a different template, so there is a copy-paste there.

Change-Id: Iff2255f10690f23de270b84c1bd0cd7de3c611a3
Signed-off-by: csatari <gergely.csatari@nokia.com>
This commit is contained in:
csatari 2017-02-23 04:04:10 +01:00
parent 0b20c8bf29
commit 7bdd14ad52
2 changed files with 20 additions and 7 deletions

View File

@ -1,7 +1,13 @@
=========================
{{cookiecutter.service}} service overview
=========================
{%- macro set_header_markup(header_text_length) -%}
{%- set servicelength = cookiecutter.service|length -%}
{%- for _ in range(0, servicelength + header_text_length) -%}={%- endfor -%}
{%- endmacro -%}
{%- macro set_header(header_text) -%}
{{ set_header_markup(header_text|length) }}
{{cookiecutter.service}}{{header_text}}
{{ set_header_markup(header_text|length) }}
{%- endmacro -%}
{{ set_header(" service overview") }}
The {{cookiecutter.service}} service provides...
The {{cookiecutter.service}} service consists of the following components:

View File

@ -1,6 +1,13 @@
=====================
{{cookiecutter.service}} service
=====================
{%- macro set_header_markup(header_text_length) -%}
{%- set servicelength = cookiecutter.service|length -%}
{%- for _ in range(0, servicelength + header_text_length) -%}={%- endfor -%}
{%- endmacro -%}
{%- macro set_header(header_text) -%}
{{ set_header_markup(header_text|length) }}
{{cookiecutter.service}}{{header_text}}
{{ set_header_markup(header_text|length) }}
{%- endmacro -%}
{{ set_header(" service") }}
.. toctree::
:maxdepth: 2