How can I customize the way selections are displayed?

When a selection is made by the user Select2 will display the text of the option by default, just like how it is displayed in a standard select box. You can override the display of the selection by setting the templateSelection option to a JavaScript function.

function template(data, container) {
  return data.text;
}

$('select').select2({
  templateSelection: template
});

Nothing is being displayed when I select an option

{% include options/not-written.html %}

I am using HTML in my selection template but it isn't displaying it

{% include options/not-written.html %}

How can I access the container where the selection is displayed?

{% include options/not-written.html %}