Twig

灵活、快速且安全的
PHP 模板引擎

a Symfony Product
您正在阅读 Twig 3.x 的文档。切换到 Twig 1.x, 2.x 的文档。

问题 & 反馈

许可

Twig 文档 基于新 BSD 许可授权。

format

format 过滤器通过替换占位符(占位符遵循 sprintf 符号)来格式化给定的字符串

1
2
3
4
{% set fruit = 'apples' %}
{{ "I like %s and %s."|format(fruit, "oranges") }}

{# outputs I like apples and oranges #}

参见

replace