我正在开发一个phonegap应用程序。我正在使用asp.net项目进行开发,然后我将所有文件编译为phonegap应用程序的静态html文件。
我想利用razor语法来处理包括文件和简单逻辑在内的事情。
有没有办法在html文件中运行razor代码?
我目前正在使用cshtml文件,但PhoneGap只接受html文件。我目前有RazorEngine将cshtml文件编译为html文件,但是我还需要更新.cshtml到.html的每个链接,事情变得复杂。
剃刀模板的代码示例......
@using System.IO;
@using RazorEngine;
@{ // render panelhtml and header html once, and then print it out below in each page
string panelHtml = Razor.Parse(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "/Views/Shared/_Panel.cshtml"));
string headerHtml = Razor.Parse(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "/Views/Shared/_HeaderLoggedIn.cshtml"));
string topHtml = Razor.Parse(File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "/Views/Shared/_HeaderLoggedIn.cshtml"));
WriteLiteral(topHtml);
}
<!-- pageDebug -->
<div data-role="page" id="pageDebug" data-add-back-btn="true">
@{ WriteLiteral(panelHtml); }
@{ WriteLiteral(headerHtml); }