LoginSignup
0
0

More than 5 years have passed since last update.

DietCubeで、twigのテンプレートファイルからconfig値を参照する方法

Posted at

DietCubeではデフォルトでconfigという変数がtemplateに渡されているので、

テンプレートファイル内から

{{ config.foo }}

のようにして参照することができる。

仕組み

Application.phpの中で、コントローラをnewした直後にsetVar()が呼ばれている。
https://github.com/mercari/dietcube/blob/1.0.3/src/Application.php#L220

setVarで渡された値は、コントローラ内でview_varsというプロパティに格納され、
https://github.com/mercari/dietcube/blob/1.0.3/src/Controller.php#L30

view_varsはrender()の際にテンプレートエンジンに渡される
https://github.com/mercari/dietcube/blob/1.0.3/src/Controller.php#L74

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0