Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

这就让您能够使用${myClass.myMethod()} FreeMarker句法,从模板获得myClass里所有的静态方法。

模板功能

TemplatingFunctions includes useful methods that you can use in your templates. The methods are exposed as cmsfn. The decode method that removes escaping of HTML on properties is is an example and the snippet below shows its use in the stkTextImage component script.包含了您可以在模板中使用的有用方法。这些方法表现为cmsfndecode方法从属性(properties)上移除HTML换码,就是这样的一个例子,下列代码片段展示了它在stkTextImage组件脚本中的使用。

Code Block
[#if content.text?has_content]
   ${cmsfn.decode(content).text}
[/#if]

DamTemplatingFunctions provides direct access to Assets and defines useful methods. The methods are exposed as damfn. See DAM templating for more information. For example:提供到Assets的直接权限以及定义有用的方法。这些方法表现为damfn。参考DAM templating以获得更多信息。例如:

Code Block
[#assign asset = damfn.getAssetForId(content.link)][#assign assetMap = damfn.getAssetMapForAssetId(content.link)]

STKTemplatingFunctions makes additional methods available for use in STK templates. The methods are exposed as stkfn. The snippet below from the promos component script contains the abbreviateString example.使附加的方法在STK模板离都可以使用。这些方法表现为stkfn。以下promos组件脚本片段包含了abbreviateString示例。

Code Block
[#assign text = stkfn.abbreviateString(text, 80)]

...