无法直接在NHAML项目页面上找到它,所以我想知道是否需要运行ASP.NET MVC才能使用NHaml,或者如果我可以在“正常”的ASP.NET网页上使用它?NHAML是否需要ASP.NET MVC?
另外,我读过,你需要拦截Sass的请求,并手动调用它的建设者?
无法直接在NHAML项目页面上找到它,所以我想知道是否需要运行ASP.NET MVC才能使用NHaml,或者如果我可以在“正常”的ASP.NET网页上使用它?NHAML是否需要ASP.NET MVC?
另外,我读过,你需要拦截Sass的请求,并手动调用它的建设者?
不,它不需要ASP.NET MVC,尽管它有一个实现。如果您愿意,甚至可以在控制台应用程序中处理NHaml模板。
问这里的答案多少有些重复:Can NHaml be used as a general purpose template engine? (outside of MVC)
报价:
是,它可以在不ASP.Net MVC 使用。我将它用于我自己的网络服务器 (但这并不意味着您有 将其用于Web服务器)。
退房我如何在这里使用它: http://webserver.codeplex.com/SourceControl/changeset/view/50874#671672
你在短期要做的就是像这样 :
TemplateEngine _templateEngine = new TemplateEngine(); // Add a type used in the template. Needed to that nhaml can
编译模板 _templateEngine.Options.AddReferences时,发现它(typeof运算 (TypeInYourAssembly));
// base class for all templates _templateEngine.Options.TemplateBaseType
= typeof(BaseClassForTemplates);
//class providing content to the engine, should implement
ITemplateContentProvider _templateEngine.Options.TemplateContentProvider =此;
// compile the template, CompiledTemplate template = _templateEngine.Compile(new List<string> {layoutName, viewPath}, typeof (TemplateImplementation)); //create a instance var instance = (NHamlView)template.CreateInstance(); // provide the view data used by the template instance.ViewData = viewData; // render it into a text writer instance.Render(writer);
+1上启用Nhaml以获取链接和信息如何使用。 :) – 2013-06-10 17:33:37
我有MVC 2现在正在运行,但下面的指南安装NHaml的时候,我似乎无法找到ControllerBuilder类的Nhaml任何地方,所以我目前搞清楚如何获得在ASp.NET MVC 2 – 2010-11-26 10:00:06