【发布时间】:2012-01-09 16:29:06
【问题描述】:
有一个cookbook 用于将全局变量添加到 twig 模板引擎,但它不会为 php 引擎做同样的事情。我该怎么做?
所以我可能有类似的东西:
# config.yml
someSortOfReferenceToThePHPEngineInstance:
calls:
- [ addGlobals, ["foo", "bar"] ]
- [ addGlobals, ["myService", "@myService"] ]
然后访问类似:
// templateName.contentType.php
<?
echo $foo; // echos "bar"
echo $myService->myMethod($foo); // echos the result of modifying "bar" with "myMethod" method of "myService" service
【问题讨论】:
-
你能写一个代码示例来说明你想怎么做吗?