2017-03-20 20 views
0

私はWebアプリケーションを構築しており、NancyとSuper Simple Viewエンジンを使用してユーザーのコンテンツをレンダリングしています。多くのページは同じレイアウト(ヘッダー、サイドメニューなど)を持っているため、マスターページには再利用可能なコンテンツが別に用意されています。スーパーシンプルビューエンジンセクションをネストされたマスターページから設定する

現在、私はROOT_FILE下

--Root_file (Master page) 
    --Home 
    --Products 
    --Contact 
    --Account (Master page) 
    --Overview 
    --Manage 
    --Post 

すべてのファイルが@Master['root_file.html']参照を持っています。アカウントのすべてのファイルは@Master['account.html']です。

私の問題は、アカウントの管理で、追加のヘッダーとしてjs-scriptを設定したいということです。私は、トップレベルのマスターページのタグを参照することで、jsを参照で追加できると考えました。

ここで概要を説明します。

Root_file.html 
<head> 
    <title>Nice little title.</title> 
    @Partial['PartialView/header_references.html'] 
    @Section['Additional_headers']; 
</head> 
<body> 
    @Section['Content']; 
</body> 

account.html 
@Master['root_file.html'] 

@Section['Content'] 
    <div class="container"> 
     <div class="row justify-content-center"> 
      @Partial['PartialView/side_menu.html'] 
      <div class="col p-3"> 
       @Section['Inner_content']; 
      </div> 
     </div> 
    </div> 
@EndSection 

manage.html 
@Master['account/overview.html'] 
@Section['Additional_headers'] 
    <script src="../../../Content/scripts/file-upload.js"></script> 
@EndSection 

私は、ネストされたマスターページを通じて@Section[Additional_headers]を設定することができることを期待していたが、結果は私の希望を反映していません。

私は間違ったことをしていますか、このようなセクションを設定することはできませんか?

答えて

0

これは古い質問ですが、私はあなたがこれを他の場所で回答したと思っていましたが、おそらく他の誰かが同じ問題を抱えています。 トップページのプレースホルダーをサブページの新しいプレースホルダーで囲みました。それは何ものでもありませんが、仕事は終わりです。あなたは

@Section['Additional_headers'] 

を参照するHTMLページで

代わりにあなたのような新しいプレースホルダに包まれたあなたのサブマスターページでこれを参照することができます:あなたはその後、任意のこの新しいセクションを参照でき

@Section['Additional_headers'] 
@Section['Sub_Additional_headers'] 
@EndSection 

このような基本的なHTMLページ

@Section['Sub_Additional_headers'] 
<label>This is in a nested master page</label> 
@EndSection 

上記の例を再利用するには、このようなものは

Root_file.html 
<head> 
    <title>Nice little title.</title> 
    @Partial['PartialView/header_references.html'] 
    @Section['Additional_headers']; 
</head> 
<body> 
@Section['Content']; 
</body> 

account.html 
@Master['root_file.html'] 

@Section['Additional_headers'] 
@Section['Sub_Additional_headers'] 
@EndSection 

@Section['Content'] 
<div class="container"> 
    <div class="row justify-content-center"> 
     @Partial['PartialView/side_menu.html'] 
     <div class="col p-3"> 
      @Section['Inner_content']; 
     </div> 
    </div> 
</div> 
@EndSection 

manage.html 
@Master['account/overview.html'] 
@Section['Sub_Additional_headers'] 
<script src="../../../Content/scripts/file-upload.js"></script> 
@EndSection 
関連する問題