在dgo.to/示例模块的email_example.Module的hook_mail()函数中,有一行:
$message['body'][] = t('@name sent you the following message:', array('@name' => $user->name), $options);
我以前没见过@thing
这么用过吗?这是如何工作的呢?那是什么惯例?
发布于 2018-02-01 13:45:56
请参考官方的D8消毒输出文档。
来自文档页
Drupal 8中有三个可用的占位符:
@variable
:当占位符替换值是字符串或MarkupInterface对象时%variable
:当占位符替换值被包装在em标记中时。:variable
:当占位符替换值是要在"href“属性中使用的URL时你可以在FormattableMarkup::placeholderFormat()文档中了解有关这些占位符的更多信息。
DRUPAL 7的
请参阅本文档https://www.drupal.org/docs/7/api/localization-api/dynamic-strings-with-placeholders
可用作替换的变量/令牌取决于周围代码的上下文,以及脚本是通过Apache调用还是从命令行调用。
https://drupal.stackexchange.com/questions/254951
复制