Data Reference ============== Every template receives a small set of objects from pyplanner. This page is a complete reference of those objects, their properties and the values they produce. Keep it open while you design - it answers "what can I put inside ``{{ }}``?". **Key topics** * The variables injected into every template (``base``, ``calendar``, ``lang`` and ``params``). * Year, Month, Day, WeekDay objects and their properties. * The ``month.table`` grid explained visually. * String representation shortcuts. * The ``loop`` variable inside ``for`` blocks. Injected variables ------------------ pyplanner passes these variables to your template: .. list-table:: :header-rows: 1 :widths: 20 20 55 * - Name - Type - Description * - ``base`` - string - Path prefix pointing to the template directory. Prefix every ``src`` and ``href`` attribute with ``{{ base }}/`` so that asset paths resolve correctly regardless of where the output file is written. Don't prepend ``{{ base }}/`` to links within the same page (starting with ``#``). * - ``calendar`` - Calendar - Entry point for all calendar data. Use it to build a Year object and to access weekday names. * - ``lang`` - string - The active display language code (e.g. ``"en"``, ``"ru"``, ``"kr"``), set by ``--lang``. ``"ko"`` is accepted as an alias for ``"kr"`` and resolves to the same value. Use the variable to apply language-specific CSS such as font families, font sizes or layout adjustments. * - ``params`` - namespace - Template parameters loaded from ``params.xml``. Access values with dot notation: ``{{ params.accent }}``, ``{{ params.colors.primary }}``. Defaults to an empty namespace when no ``params.xml`` exists. See :doc:`template-parameters` for details on declaring and overriding parameters. Calendar -------- The ``calendar`` object itself has two things you will use: .. list-table:: :header-rows: 1 :widths: 30 15 50 * - Expression - Type - Description * - ``calendar.year(2026)`` - Year - Build a Year object for the given year number. * - ``calendar.weekdays`` - tuple - Seven WeekDay objects starting from the configured first day of the week. Defaults to Monday through Sunday; changes when ``--first-weekday`` or ``--country`` is used. * - ``calendar.firstweekday`` - int - The first day of the week as a number (0 = Monday ... 6 = Sunday). * - ``calendar.lang`` - string - The active display language code (same value as the top-level ``lang`` variable). ``calendar.weekdays`` example (default, Monday start): **Template:** .. code-block:: html+jinja %% for wd in calendar.weekdays {{ wd.name }} %% endfor **Output:** .. code-block:: text Monday Tuesday Wednesday Thursday Friday Saturday Sunday When ``--first-weekday sunday`` is used, the same loop outputs: .. code-block:: text Sunday Monday Tuesday Wednesday Thursday Friday Saturday Year ---- Returned by ``calendar.year()``. .. list-table:: :header-rows: 1 :widths: 25 10 20 40 * - Property - Type - Example - Description * - ``value`` - int - ``2026`` - The year number. * - ``months`` - list - (12 Month objects) - All months, January through December. * - ``id`` - string - ``"2026"`` - Identifier string. Useful for HTML ``id`` attributes. * - ``isleap`` - bool - ``false`` - Whether the year is a leap year. * - ``days()`` - iterator - (365 or 366 Day objects) - Every day in the year, in order. **String representation:** ``{{ year }}`` outputs the year number, for example ``2026``. Month ----- Each item in ``year.months``. .. list-table:: :header-rows: 1 :widths: 25 10 20 40 * - Property - Type - Example - Description * - ``value`` - int - ``1`` - Month number (1 = January, 12 = December). * - ``name`` - string - ``"January"`` - Full month name (translated when ``--lang`` is used). * - ``short_name`` - string - ``"Jan"`` - Abbreviated month name (translated when ``--lang`` is used). * - ``days`` - list - (28-31 Day objects) - Every day in the month, in order. * - ``table`` - list of lists - (see below) - Calendar grid for rendering tables. * - ``id`` - string - ``"2026-01"`` - Identifier in ``YYYY-MM`` format. **String representation:** ``{{ month }}`` outputs the month name, for example ``January``. Understanding ``month.table`` ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ``month.table`` is a list of weeks. Each week is a list of seven slots - one per weekday, ordered to match ``calendar.weekdays``. A slot contains a Day object or ``None`` if that weekday falls outside the month. The column order depends on the configured first day of the week. January 2026 starts on Thursday. With the default Monday start the table looks like this:: Mon Tue Wed Thu Fri Sat Sun ---- ---- ---- ---- ---- ---- ---- None None None 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 None In your template you loop over weeks (rows) and then over days (cells). Check for ``None`` before printing: .. code-block:: html+jinja %% for week in month.table