symfony - FOSUserBundle 理解 twig 模板变量

标签 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”

最佳答案

这些是 Symfony bundle 中常见的翻译键 .

这里是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%'

关于symfony - FOSUserBundle 理解 twig 模板变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35830315/

相关文章:

php - 是否可以在 Symfony 2 中创建自定义表单字段属性?

forms - 表单验证 - 我收到了两次标签

c++ - 如何将特定回调传递给模板函数?

c++ - 这个例子中的 `typename`是什么意思?

Twig 在 'if variable is defined' 中运行,即使定义了变量

arrays - Twig 中的输出数组

php - symfony2.8 与 php 7.2 中的 session_cache_limiter 错误

symfony - 将对象传递给自定义选民?

css - django 模板 forloop.counter 问题

symfony - 查找当前 View 的twig文件