我有兩個應用程序。其中一個是網絡應用程序,另一個是移動應用程序。我正在嘗試從網絡應用程序解析其中一個視圖,併爲移動應用程序編譯一個html文件。我認爲在Web應用程序的結構如下使用剃刀引擎解析cshtml文件
- App.cshtml
- partialview1.cshtml
- partialview2.cshtml
- ....
該Web應用程序內置在asp.net mvc中,我正在使用Microsoft Visual Studio Cordova構建移動應用程序。
我有一個單獨的項目,它需要App.cshtml併爲移動應用程序編譯index.html。這裏是我的App.cshtml的結構文件
@model Account
@{
Layout = "~/Views/Shared/_Layout.cshtml";
ViewBag.Title = Texts.App;
}
@section head{
@Styles.Render("~/Content/css/app")
}
@section scripts {
@Scripts.Render("~/bundles/moment")
@Scripts.Render("~/bundles/tippnett/app")
<script>
var userId = '@Model.Id';
TippNett.StartApp();
</script>
}
<div id="appview" class="loading">
<div id="workspace" class="map_canvas">
<section class="other-stuff">
@RenderPage("~/Views/Home/subPagesForApp/_locationWindow.cshtml")
@RenderPage("~/Views/Home/subPagesForApp/_moveLocationWindow.cshtml")
@RenderPage("~/Views/Home/subPagesForApp/_orderWindow.cshtml")
@RenderPage("~/Views/Home/subPagesForApp/_createLocation.cshtml")
@RenderPage("~/Views/Home/subPagesForApp/_ordersListWindow.cshtml")
@RenderPage("~/Views/Home/subPagesForApp/_reportAbuse.cshtml")
</section>
</div>
<div class="locations-list" data-bind="visible:locationView">
@RenderPage("~/Views/Home/subPagesForApp/_locationList.cshtml")
</div>
<div id="loading-wale">
<div id="loading-info">
<div>
<i class="spinner"> </i>
</div>
<div>@Texts.Loading</div>
</div>
</div>
</div>
<div class="show-for-small" id="stick-menu" data-role="footer">
<div class="icon-bar three-up ">
<a class="item active locations" data-bind="click: openLocationView.bind($data,true)">
<i class="fi-marker"></i>
<label>@Texts.Location</label>
</a>
<a class="item maps" data-bind="click: openMapView.bind($data,true)">
<i class="fi-map"></i>
<label>@Texts.Maps</label>
</a>
<a class="item notifications" data-bind="click: openOrders.bind($data,true)">
<i class="fi-list"></i>
<span class="order-notification-counter notification-counter" data-bind=" text: orders().length,visible: orders().length > 0"></span>
<span class="matches-notification-counter notification-counter" data-bind=" text: matches().length,visible: matches().length > 0"></span>
<label>
@Texts.OrdersLabel
</label>
</a>
</div>
我已經調查RazorEngine.Razor.Compile,但沒有運氣。我也看過這個圖書館以及http://razorengine.codeplex.com/,但無法獲得任何地方。
你能詳細解釋一下「沒有運氣」嗎?當項目轉移到github時,最新版本可以在這裏找到https://github.com/Antaris/RazorEngine。 – matthid
我爲html的東西做了一個自定義模板。我已經能夠迎合html.raw和pagerender的東西,但我正在努力與html.partial功能。你能否提供一個餐飲功能的例子? – mohsinali1317