FOSUserBundle了解twig模板变量

时间:2016-03-06 17:50:58

标签: symfony templates twig fosuserbundle

在layout.html.twig文件中;

{% if is_granted("IS_AUTHENTICATED_REMEMBERED") %}
        {{ 'layout.logged_in_as'|trans({'%username%': app.user.username}, 'FOSUserBundle') }} |
        <a href="{{ path('fos_user_security_logout') }}">
            {{ 'layout.logout'|trans({}, 'FOSUserBundle') }}
        </a>
    {% else %}
        <a href="{{ path('fos_user_security_login') }}">{{ 'layout.login'|trans({}, 'FOSUserBundle') }}</a>
    {% endif %}

什么是布局属性?它似乎输出了我在html页面中的字符串,即'layout.logged_in_as'和'layout.logout'

1 个答案:

答案 0 :(得分:4)

这些是Symfony捆绑包常见的翻译密钥

以下是the layout translation definitions that would be translated to English

layout:
  logout: 'Log out'
  login: 'Log in'
  register: Register
  logged_in_as: 'Logged in as %username%'