2017-10-25 7 views
1

어떻게 로직을 Twig 2.x로 변환합니까?나뭇 가지 복잡한 배열 변환

<?php if (isset($pricerunner_category[$category['category_id']])) { echo $pricerunner_category[$category['category_id']]; } ?> 

답변

1

attribute 기능으로 가능해야합니다. is defined이 필요한 아닌지

{% if attribute(pricerunner_category, category.category_id) is defined %} 
    {{ attribute(pricerunner_category, category.category_id) }} 
{% endif %} 

https://twig.symfony.com/doc/2.x/functions/attribute.html

은 물론, 문서에 근거를 추가하지 않습니다.

관련 문제