【问题标题】:TVML: adding new lines to a description textTVML:向描述文本添加新行
【发布时间】:2015-12-18 22:19:13
【问题描述】:

用 Apple TV 的 TVML 进行实验:我正在使用产品模板,我想在描述字段中添加回车,使它看起来有点像一个列表。

这是一个简单的例子:

var Template = function() { return `<?xml version="1.0" encoding="UTF-8" ?>
    <document>
        <productTemplate>
            <banner>
                <infoList>
                </infoList>
                <stack>
                    <title>Big Title</title>
                    <description>
                        Line one
                        Line two
                    </description>
                </stack>
            </banner>
        </productTemplate>
    </document>`
}

我尝试过\n&amp;#xD&amp;#xA,甚至是这样的:

<![CDATA[
  Line 1 <br />
  Line 2 <br />
]]>

但这些都不起作用。有没有办法在 TVML 描述中加入换行符?

【问题讨论】:

    标签: apple-tv tvml


    【解决方案1】:

    将此代码放在template.xml.js 中并通过苹果的TVMLCatalog 示例中的Presenter.js 加载它:

    <stack>
        <description>Insert your \n username (tipically your ID)</description>
    </stack>
    

    渲染

    【讨论】:

    • 是的,这行得通。 (不太明白为什么它以前对我不起作用——这是我尝试的第一件事——但现在对我起作用了)
    • 看起来“sometext\n moreText”或“some text\nmoretext”不起作用。你需要空间。
    【解决方案2】:

    这也有效:

    var Template = function() {
      const description = `
        Line 1
        Line 2
      `.trim();
    
      return `<?xml version="1.0" encoding="UTF-8" ?>
        <document>
          <productTemplate>
            <banner>
              <infoList>
              </infoList>
              <stack>
                <title>Big Title</title>
                <description>
                  ${description}
                </description>
              </stack>
            </banner>
          </productTemplate>
        </document>`
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-10-19
      • 1970-01-01
      • 2012-01-31
      • 1970-01-01
      • 2021-09-10
      • 2016-04-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多