Mat*_*hew 2 html include liquid jekyll
我创建了image
一个很像Jekyll 文档中的包含。
如果提供,我将alt
根据alt
变量设置标签,否则设置一个默认标签来尝试让自己羞于提供一个:
alt="{{ include.alt | default: "Whoops! alt tag not provided. Please let me know via the contact page"}}"
我还有一个可选的标题,它可能是alt
标签的合理替代品(请原谅双关语)(如果caption
已设置但未设置alt
)。
我试过了,{{ include.alt | include.caption | default: "Whoops! alt tag not ..."}}
但是当alt
为空白并设置标题时,它仍然使用默认值。
有没有一种优雅的方法来做到这一点,还是我需要使用多个 if/unless 块?