使用管道时在撇号中删除帮助中的字符

问题描述 投票:1回答:1

我正在创建的作品中有一个字段架构。向其中添加帮助值(带有管道)会删除管道之前的所有文本。

例如

{
  name: 'text_example'
  type: 'string',
  help: 'Key value pairs, e.g. key|value',
  textarea: true
}

导致显示“值”的字段上的帮助文本

是否正在清洗?需要吗?我尝试了所有类型的方法来尝试使其工作,使用html和ascii代码添加转义字符\。使用String.fromCharCode(124)。什么都不允许在文本中使用管道。

apostrophe-cms
1个回答
0
投票

help字符串正在通过i18n模块运行,该模块在管道字符周围存在已知问题。

解决方法是使用htmlHelp属性而不是标准的help字段属性,并像这样对管道进行转义

 {
  name: 'test',
  label: 'Test',
  htmlHelp: 'Extending this logic, the chive of \| a rocket becomes an undamped wholesaler.',
  type: 'string'
 }

这将通过转换实体的Nunjucks safe过滤器运行。

© www.soinside.com 2019 - 2024. All rights reserved.