Loading custom template from external file

hello,I have a complex custom template for a List page with many fields, I wish to be able to load the template from external file like (MyTemplate.cshtml) so I can use VSCode to edit it and get all its benefits like autocomplete, code formatting, brackets matching, code coloring and so.I am using @Html.Partial(“MyTemplate”) in the CustomTemplateBody and was able to load my rows from MyTemplate.cshtml file when it contains only simple html, but as soon as I add any of my fields like : {{{ID}}} the template will not render and the body will shows nothing between the header and the footer.I have also tried to use the format {{include tmpl=getTemplate(“#tpx@(i)_MyTable_ID”)/}} instead of {{{ID}}} but I have recived error that it could not find (i).This worked for me: @(MyTable_List.ID.ViewValue) but it only worked for simple fields and produced only plain text , and did not give me the expected result like when using hyperlinks in View Tag.is there any way to make this possible? I have about 5 more complex templates with the same needs, so it will help me alot.Thank you

I have fixed the problem of missing (i) by passing it to my template file in this way:
@Html.Partial(“MyTemplate”,i)
and was able to use it inside my external template file:@{ int i = @Model;}

{{include tmpl=getTemplate("#tpx@(i)_MyTable_ID")/}}
The biggest benefit I got here (beside using my favorite editor VSCode) is that I can modify the template file and save it and preview the results immediately by just refreshing the webpage without having to re-generate my project with every change, which will save me a lot of time and effort.Does this method affect performance in general? I am still better hearing your opinion and welcome any suggestion.

I believe your approach is fine. However, Custom Template is generated in .cshtml, by default it is not compiled (unless to enable the advanced setting “Razor runtime compilation”) so you can just modify it and refresh your browser.

ok, I will continue with this approach for the moment, thank you very much for your time.