According to the "Model-View-Controller" methodology, custom component templates must not generate anything except for the HTML layout code.

A Controller is the subject for implementation by the component core. The controller's main task is to process the input parameters, call the model methods, process information and pass it over to the view.

A Model is the Bitrix Framework API classes, methods and functions. The controllers call the model to store, retrieve and search data.

A View is the component template. It renders information to a viewer (a website visitor) by creating a valid HTML layout.

A component template should passively receive information from the controller; it must not call the model or use any other active resources. The component template code should be clear and understandable for an HTML designer, not only for the developer who creates it.

The presence of any logic that pertains to the controller or model will result in unreasonably complex component architecture, and may incur development errors and increase maintenance cost.