如何在路径字符串中使用参数

how use parameters in the path-string

我正在使用 Symfony2 和 TWIG。使用 "path" 我将打开第二个页面并设置一些参数。

{% set place = "The City" %}
<tr>
    <td class="tdstellenangebot_zelle">
        <a href="#" onclick="anzeige_job('{{ path("_anzeige_job",{kznr:102,ort:"unseren Standort in " {{ place }} ,filiale:1} ) }}')">
            The jobdescription
        </a>
    </td>
    <td class="tdstellenangebot_zelle textBold">{{ place }} </td>
</tr>

但是脚本不工作。

如何使用变量设置路径中的位置?

非常感谢您的帮助。

您需要简单的串联:

{% set place = "The City" %}
<tr>
    <td class="tdstellenangebot_zelle">
        <a href="#" onclick="anzeige_job('{{ path("_anzeige_job", { kznr: 102, ort:"unseren Standort in " ~ place, filiale: 1 }) }}')">
            The jobdescription
        </a>
    </td>
    <td class="tdstellenangebot_zelle textBold">{{ place }} </td>
</tr>

看看波浪符号 ~。它类似于JavaScript中的+和PHP中的.,用于连接字符串。