ASP.net MVC或模板简单的C#生成文件 [英] ASP.net MVC or simple C# generating file from template
本文介绍了ASP.net MVC或模板简单的C#生成文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个Asp.Net的mvc 5应用程序的后台。 我想在我的控制器添加上的服务器文件夹中动态创建的HTML功能。 我想要这个网站是从模板生成。 例如:
I have an Asp.Net Mvc 5 application backend. I want to add in my controller a function that creates html on the fly in a server folder. I want that this html is generated from template. Example:
模板:
<html><head/> <body> {CSharpVar} </body> </html>
在我的控制器:
in my controller:
MyObject mObj= new MyObject();
mObj.CSharpVar= "String TEst";
MyWantedClass.CreateHtml(htmlTemplate,mObj,outputPath);
什么是用最好的方式还是最好的类?
What is the best way or best class to use?
推荐答案
您可以尝试使用 MustacheSharp (的NuGet这里),这是一个的把手模板引擎,编译你的模板,并使用自定义生成操作在Visual Studio,使他们重新编译改变的时候。
You could try using MustacheSharp (nuget here), which is a Handlebars template engine, to compile your templates, and use a custom build action in visual studio so they recompile when changed.
这篇关于ASP.net MVC或模板简单的C#生成文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文