Using a templating language like Jinja2, you could use the following template:
<html>
<head></head>
<body>
<h2>The following changes have been made to the main page:</h2>
<h3> Instruction IDs Added</h3>
{% for instruction_id in added_instruction_ids %}
<a href="{{instruction_id.url}}">Instruction ID #{{instruction_id.id}}</a>
{% endfor %}
<h3> Instruction IDs Removed</h3>
{% for instruction_id in removed_instruction_ids %}
<a href="{{instruction_id.url}}">Instruction ID #{{instruction_id.id}}</a>
{% endfor %}
</p>
</body>
</html>
You could even achieve your "dynamic template" request by using if statements:
<html>
<head></head>
<body>
<h2>The following changes have been made to the main page:</h2>
{% if len(added_instruction_ids) %}
<h3> Instruction IDs Added</h3>
{% endif %}
{% for instruction_id in added_instruction_ids %}
<a href="{{instruction_id.url}}">Instruction ID #{{instruction_id.id}}</a>
{% endfor %}
{% if len(removed_instruction_ids) %}
<h3> Instruction IDs Removed</h3>
{% endif %}
{% for instruction_id in removed_instruction_ids %}
<a href="{{instruction_id.url}}">Instruction ID #{{instruction_id.id}}</a>
{% endfor %}
</p>
</body>
</html>
Note: the above examples assume that the following data is passed to the template engine:
{
added_instruction_ids: [
{
id: X,
url: link_to_url_of_instruction_id_X
}, {
id: Y,
url: link_to_url_of_instruction_id_Y
}
],
removed_instruction_ids: [
{
id: A,
url: link_to_url_of_instruction_id_A
}
]
}