gpt4 book ai didi

javascript - 无法在 Sylius/Symfony 2 模式框中添加换行符

转载 作者:行者123 更新时间:2023-12-03 10:19:46 25 4
gpt4 key购买 nike

我在使用 SF2/Sylius 模式框时引入换行符时遇到问题。

在我的 Controller 中,我有这个:

    $view = $this
->view()
->setTemplate($this->config->getTemplate('update.html'))
->setData(array(
$this->config->getResourceName() => $resource,
'form' => $form->createView(),
'confirmation_message' => $this->get('translator')->trans('ayrshireminis.cars.backend.messages.delete_category')
))
;

在我的 YAML 中,我有以下内容:

messages:
delete_category: |
Are you sure you want to delete this category?

WARNING - Deleting this category will delete any of its subcategories and assets!

模态框的标记如下所示:

<div class="modal-body">
{{ confirmation_message is defined ? confirmation_message|raw : 'sylius.confirmation.message'|trans }}

但是,输出看起来像这样(没有中断):

enter image description here

我已阅读this帖子,但解决方案对我不起作用。

最佳答案

我的翻译文件和 Twig 模板中有以下构造,适用于这种情况:

在翻译文件中:

showBills:
printDate: 'Date <br> Other Date'

在模板内:

{{ 'showBills.printDate'|trans|raw }}

这对我来说绝对有效!

所以我猜你需要这样的东西:

<div class="modal-body">
{{ confirmation_message is defined ? confirmation_message|raw : 'sylius.confirmation.message'|trans|raw }}

关于javascript - 无法在 Sylius/Symfony 2 模式框中添加换行符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29696814/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com