0

これは私のコントローラーです:

class HomeController extends BaseController {

public $layout = 'default';

public function index()
{
    $page = Page::find(1);
    $this->layout->page_title = $page->page_title;


    $allPages = Page::lists('title');
    // Give the page it's needed content
    $this->layout->nest('content', 'pages.home', array(
        'pageHeading' => 'Rendered with Mustache.php',
        'pageContent' => $allPages
    ));   
}

}

というマスター テンプレートdefault.blade.phpと という子ページ テンプレートがありhome.mustasheます。

home.mustache問題は、テンプレート内のすべてのページ タイトルを含む配列を使用したいということです。home.mustache配列をテンプレートに追加するにはどうすればよいですか?

現在のコードでは、次のエラーが発生します。Array to string conversion

私が使用する口ひげパッケージは次のとおりです。口ひげパッケージへのリンク

4

2 に答える 2

0

Mustache パッケージのドキュメントによると、配列は次のように処理されます。

{{#posts}}
    {{> posts._post}}
{{/posts}}
于 2013-10-16T15:37:56.887 に答える