<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def render_chart_to_file(self, template_name: str, chart: Any, path: str):
 """ Render a chart or page to local html files. :param chart: A Chart or Page object :param path: The destination file which the html code write to :param template_name: The name of template file. """

        tpl = self.env.get_template(template_name)
        html = tpl.render(chart=self.generate_js_link(chart))
        write_utf8_html_file(path, self._reg_replace(html))