使用這個枝杈模板不工作:嫩枝「微調」預期
{% for line in lines%}
{{line}} after trim('.php') is: {{line|trim('.php')}}<br>
{% endfor %}
在Silex的使用控制器使上面的模板:
$app->get('/try', function() use ($app)
{
$lines=[];
$lines[]='123.php';
$lines[]='news.php';
$lines[]='map.php';
return $app['twig']->render('try.html.twig', ['lines'=>$lines]);
}
);
我收到以下輸出:
123.php after trim('.php') is: 123
news.php after trim('.php') is: news
map.php after trim('.php') is: ma
注意最後修剪:map.php
應該變成map
,但現在是ma
。
很好的解釋。謝謝。 – TaylorR