自宅でPHPを使用しながら、職場でASP.NETMVC3を使用しています。CodeIgniterでMVC3のセクション機能を使用したいのですが、そのような機能はありますか?
ASP.NET MVC3の例(テストされていません):
<!-- A view, that serves the content -->
@section Head{
<script src="myscript.js"></script>
}
<p>This is my main content -
I require myscript.js to be included on my page,
so I specify a head section, which the header of my page will render</p>
<!-- ANOTHER view, that serves the content -->
@section Head{
<script src="otherscript.js"></script>
<link rel="stylesheet" type="text/css" href="somestyle.css" />
}
<p>Some OTHER view, with OTHER dependencies!</p>
<!-- Header File, where I include CSS and JS! -->
<head>
<script src="jquery.js"></script>
@Html.Section("Head")
</head>
ポイントは、たとえば、特定のビューでスクリプトファイルを含めたいので、セクションにを追加する<script>
と、そのセクションがヘッダー(別のビューにあります)にレンダリングされます。