(self, data: T.Dict[str, T.Any], file_id: str, template_name: T.Optional[str] = None)
Render the template mustache files and write the result
Render the template mustache files and write the result
Render the template mustache files and write the result
def _write_template(self, data: T.Dict[str, T.Any], file_id: str, template_name: T.Optional[str] = None) -> None:
        ''' Render the template mustache files and write the result '''
        template_dir = Path(__file__).resolve().parent / 'templates'
        template_name = template_name or file_id
        template_name = f'{template_name}.mustache'
        template_file = template_dir / template_name

        # Import here, so that other generators don't also depend on it
        import chevron
        result = chevron.render(
            template=template_file.read_text(encoding='utf-8'),
            data=data,
            partials_path=template_dir.as_posix(),
            warn=True,
        )

        self._write_file(result, file_id)
def _write_template ( self , data : T . Dict [ str , T . Any ] , file_id : str , template_name : T . Optional [ str ] = None ) -> None : template_dir = Path ( __file__ ) . resolve ( ) . parent / 'templates' template_name = template_name or file_id template_name = f'{template_name}.mustache' template_file = template_dir / template_name # Import here, so that other generators don't also depend on it import chevron result = chevron . render ( template = template_file . read_text ( encoding = 'utf-8' ) , data = data , partials_path = template_dir . as_posix ( ) , warn = True , ) self . _write_file ( result , file_id )