【问题标题】:Format HTML in Scriban在 Scriban 中格式化 HTML
【发布时间】:2021-05-28 14:57:53
【问题描述】:

将 scriban 与 SXA 一起使用,我们注意到生成的 HTML 有很多空格,例如:

<div id=”dv1”>


           <div id=”dv2”>

这是因为在 scriban 中我们在使用 id=de2 渲染 div 之前有 if 条件,有没有办法格式化 html ?

【问题讨论】:

    标签: sitecore sitecore-sxa scriban


    【解决方案1】:

    如果您发布您正在使用的 Scriban sn-p 将会很有帮助。我怀疑您需要在if 代码块末尾使用~ 运算符,如here 所述

    例如:

    <div 1>
    
    
    {{- #eat all whitespace to left including newlines
        if true
        #eat whitespace but not newlines to right  ~}}
    
        <div 2>
    {{end}}
     
    

    输出

    <div 1>
        <div 2>
    

    您可以使用this 工具来尝试格式化。

    【讨论】:

      猜你喜欢
      • 2023-01-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-28
      • 1970-01-01
      • 2018-12-22
      • 2021-09-06
      相关资源
      最近更新 更多