.. _htmlTemplates:
HTML templates
==============
Every page in an HTML disassembly is built from a single full-page template and
several subtemplates defined by :ref:`template` sections in the ref file.
A template may contain 'replacement fields' - identifiers enclosed by braces
(``{`` and ``}``) - that are replaced by appropriate content (typically derived
from the skool file or a ref file section) when the template is formatted. The
following 'universal' identifiers are available in every template:
* ``Game`` - a dictionary of the parameters in the :ref:`ref-game` section
* ``SkoolKit`` - a dictionary of parameters relevant to the page currently
being built
The parameters in the ``SkoolKit`` dictionary are:
* ``index_href`` - the relative path to the disassembly index page
* ``page_header`` - the page header text (as defined in the :ref:`pageHeaders`
section)
* ``page_id`` - the page ID (e.g. ``GameIndex``, ``MemoryMap``)
* ``title`` - the title of the page (as defined in the :ref:`titles` section)
The parameters in a dictionary are accessed using the ``[param]`` notation;
for example, wherever ``{Game[Copyright]}`` appears in a template, it is
replaced by the value of the ``Copyright`` parameter in the :ref:`ref-game`
section when the template is formatted.
In addition to the universal identifiers, the following page-level identifiers
are available in every full-page template:
* ``m_javascript`` - replaced by any number of copies of the
:ref:`t_javascript` subtemplate
* ``m_stylesheet`` - replaced by one or more copies of the :ref:`t_stylesheet`
subtemplate
* ``t_footer`` - replaced by a copy of the :ref:`t_footer` subtemplate
.. _t_Asm:
Asm
---
The ``Asm`` template is the full-page template that is used to build
disassembly pages.
The following identifiers are available (in addition to the universal and
page-level identifiers):
* ``disassembly`` - replaced by sequences of copies of the
:ref:`t_asm_instruction` subtemplate, punctuated by copies of the
:ref:`t_asm_comment` subtemplate
* ``entry`` - a dictionary of parameters corresponding to the current memory
map entry (see below)
* ``next_entry`` - a dictionary of parameters corresponding to the next memory
map entry (see below)
* ``prev_entry`` - a dictionary of parameters corresponding to the previous
memory map entry (see below)
* ``registers_input`` - replaced by any number of copies of the
:ref:`t_asm_register` subtemplate
* ``registers_output`` - replaced by any number of copies of the
:ref:`t_asm_register` subtemplate
The parameters in the ``prev_entry``, ``entry`` and ``next_entry`` dictionaries
are:
* ``address`` - the address of the entry (may be in decimal or hexadecimal
format, depending on how it appears in the skool file, and the options passed
to :ref:`skool2html.py`)
* ``annotated`` - '1' if any instructions in the entry have a non-empty comment
field, '0' otherwise
* ``byte`` - the LSB of the entry address
* ``description`` - the entry description
* ``exists`` - '1' if the entry exists, '0' otherwise
* ``href`` - the relative path to the disassembly page for the entry (useful
only for ``prev_entry`` and ``next_entry``)
* ``label`` - the ASM label of the first instruction in the entry
* ``labels`` - '1' if any instructions in the entry have an ASM label, '0'
otherwise
* ``location`` - the address of the entry as a decimal number
* ``map_href`` - the relative path to the entry on the 'Memory Map' page
* ``page`` - the MSB of the entry address
* ``size`` - the size of the entry in bytes
* ``title`` - the title of the entry
* ``type`` - the block type of the entry ('b', 'c', 'g', 's', 't', 'u' or 'w')
The ``entry`` dictionary also contains the following parameters:
* ``input`` - '1' if there are input register values defined, '0' otherwise
* ``output`` - '1' if there are output register values defined, '0' otherwise
To see the default ``Asm`` template, run the following command::
$ skool2html.py -r Template:Asm$
.. _t_AsmAllInOne:
AsmAllInOne
-----------
The ``AsmAllInOne`` template is a full-page template that may be used to build
a disassembly on a single page (by setting the ``AsmSinglePageTemplate``
parameter in the :ref:`ref-Game` section).
The following identifier is available (in addition to the universal and
page-level identifiers):
* ``m_asm_entry`` - replaced by one or more copies of the :ref:`t_asm_entry`
subtemplate
To see the default ``AsmAllInOne`` template, run the following command::
$ skool2html.py -r Template:AsmAllInOne
.. versionadded:: 5.3
.. _t_GameIndex:
GameIndex
---------
The ``GameIndex`` template is the full-page template that is used to build the
disassembly index page.
The following identifier is available (in addition to the universal and
page-level identifiers):
* ``m_index_section`` - replaced by any number of copies of the
:ref:`t_index_section` subtemplate
To see the default ``GameIndex`` template, run the following command::
$ skool2html.py -r Template:GameIndex
.. _t_MemoryMap:
MemoryMap
---------
The ``MemoryMap`` template is the full-page template that is used to build
memory map pages and the 'Game status buffer' page.
The following identifiers are available (in addition to the universal and
page-level identifiers):
* ``MemoryMap`` - a dictionary of the parameters in the corresponding
:ref:`memoryMap` section
* ``m_map_entry`` - replaced by one or more copies of the :ref:`t_map_entry`
subtemplate
To see the default ``MemoryMap`` template, run the following command::
$ skool2html.py -r Template:MemoryMap
.. _t_Page:
Page
----
The ``Page`` template is the full-page template that is used to build custom
non-box pages defined by :ref:`page` sections.
The following identifier is available (in addition to the universal and
page-level identifiers):
* ``content`` - replaced by the value of the ``PageContent`` parameter in the
corresponding :ref:`page` section
To see the default ``Page`` template, run the following command::
$ skool2html.py -r Template:Page
.. _t_Reference:
Reference
---------
The ``Reference`` template is the full-page template that is used to build
:ref:`box pages `.
The following identifiers are available (in addition to the universal and
page-level identifiers):
* ``entries`` - replaced by one or more copies of the :ref:`t_list_entry`
subtemplate (when the page's ``SectionType`` is ``BulletPoints`` or
``ListItems``), or the :ref:`t_reference_entry` subtemplate
* ``m_contents_list_item`` - replaced by one or more copies of the
:ref:`t_contents_list_item` subtemplate
To see the default ``Reference`` template, run the following command::
$ skool2html.py -r Template:Reference
.. _t_anchor:
anchor
------
The ``anchor`` template is the subtemplate used to format a page anchor (by
default, a ```` element with an ``id`` attribute).
The following identifier is available (in addition to the universal
identifiers):
* ``anchor`` - the value of the ``id`` attribute
To see the default ``anchor`` template, run the following command::
$ skool2html.py -r Template:anchor
.. _t_asm_comment:
asm_comment
-----------
The ``asm_comment`` template is the subtemplate used by the :ref:`t_Asm`
full-page template and the :ref:`t_asm_entry` subtemplate to format block start
comments, mid-block comments and block end comments.
The following identifiers are available (in addition to the universal
identifiers):
* ``entry`` - a dictionary of parameters corresponding to the current memory
map entry (see :ref:`t_Asm`)
* ``m_paragraph`` - replaced by one or more copies of the :ref:`t_paragraph`
subtemplate
* ``t_anchor`` - replaced by a copy of the :ref:`t_anchor` subtemplate (when
formatting a block start comment or a mid-block comment), or by an empty
string (when formatting a block end comment)
To see the default ``asm_comment`` template, run the following command::
$ skool2html.py -r Template:asm_comment
.. _t_asm_entry:
asm_entry
---------
The ``asm_entry`` template is the subtemplate used by the :ref:`t_AsmAllInOne`
full-page template to format the disassembly of a memory map entry.
The following identifiers are available (in addition to the universal
identifiers):
* ``disassembly`` - replaced by sequences of copies of the
:ref:`t_asm_instruction` subtemplate, punctuated by copies of the
:ref:`t_asm_comment` subtemplate
* ``entry`` - a dictionary of parameters corresponding to the memory map entry;
the parameters in this dictionary are the same as those in the ``entry``
dictionary in the :ref:`t_Asm` template
* ``registers_input`` - replaced by any number of copies of the
:ref:`t_asm_register` subtemplate
* ``registers_output`` - replaced by any number of copies of the
:ref:`t_asm_register` subtemplate
To see the default ``asm_entry`` template, run the following command::
$ skool2html.py -r Template:asm_entry
.. versionadded:: 5.3
.. _t_asm_instruction:
asm_instruction
---------------
The ``asm_instruction`` template is the subtemplate used by the :ref:`t_Asm`
full-page template and the :ref:`t_asm_entry` subtemplate to format an
instruction (including its label, address, operation and comment).
The following identifiers are available (in addition to the universal
identifiers):
* ``address`` - the address of the instruction (may be in decimal or
hexadecimal format, depending on how it appears in the skool file, and the
options passed to :ref:`skool2html.py`)
* ``annotated`` - '1' if the instruction has a comment field, '0' otherwise
* ``called`` - '2' if the instruction is an entry point, '1' otherwise
* ``comment`` - the text of the instruction's comment field
* ``comment_rowspan`` - the number of instructions to which the comment field
applies
* ``entry`` - a dictionary of parameters corresponding to the memory map entry
that contains the instruction (see :ref:`t_Asm`)
* ``label`` - the instruction's ASM label
* ``location`` - the address of the instruction as a decimal number
* ``operation`` - the assembly language operation (e.g. 'LD A,B'), with operand
hyperlinked if appropriate
* ``t_anchor`` - replaced by a copy of the :ref:`t_anchor` subtemplate
To see the default ``asm_instruction`` template, run the following command::
$ skool2html.py -r Template:asm_instruction
.. versionchanged:: 6.3
Added the ``location`` identifier.
.. _t_asm_register:
asm_register
------------
The ``asm_register`` template is the subtemplate used by the :ref:`t_Asm`
full-page template and the :ref:`t_asm_entry` subtemplate to format each row in
a table of input register values or output register values.
The following identifiers are available (in addition to the universal
identifiers):
* ``description`` - the register's description (as it appears in the register
section for the current entry in the skool file)
* ``entry`` - a dictionary of parameters corresponding to the current memory
map entry (see :ref:`t_Asm`)
* ``name`` - the register's name (e.g. 'HL')
To see the default ``asm_register`` template, run the following command::
$ skool2html.py -r Template:asm_register
.. _t_contents_list_item:
contents_list_item
------------------
The ``contents_list_item`` template is the subtemplate used by the
:ref:`t_Reference` full-page template to format each item in the contents list
on a :ref:`box page `.
The following identifiers are available (in addition to the universal
identifiers):
* ``href`` - the URL to the entry on the page
* ``title`` - the entry title
To see the default ``contents_list_item`` template, run the following command::
$ skool2html.py -r Template:contents_list_item
.. _t_footer:
footer
------
The ``footer`` template is the subtemplate used by the full-page templates to
format the ``