在Soy V2中创建参数的正确方法是什么?

时间:2019-04-29 23:59:50

标签: google-closure-templates soy-templates

这是我的代码:

{template .someTemplate}
    {@param? icon : string} /** CSS class that loads and styles the icon */
    {@param? headlineHtml : any} /** Headline text with optional html for styling */
    {@param? textHtml : any} /** Subtext with optional html for styling */
    {@param? buttonText : string} /** The call to action text for the button */
    {@param? rejectButtonText : string} /** The text for choosing to reject the call to action */

....

当我尝试编译时,出现错误消息:

Exception in thread "main" com.google.template.soy.base.SoySyntaxException: In file ./myfile.soy:7, template com.namespace.someTemplate: Not all code is in Soy V2 syntax (found tag {@param? icon : string} not in Soy V2 syntax).`

我在网上找到的唯一信息似乎表明这是正确的语法(根据我发现的{Google's site herethis cheat sheet),Google对“ soy v2”的搜索没有给我任何信息结果说明什么是正确的Soy V2语法。

定义这些参数的正确方法是什么?

1 个答案:

答案 0 :(得分:0)

这看起来像是语法:

{namespace test}

/**
 * This is a template.
 * @param name The name to say hello to
 */
{template .main}
Hello {$name}
{/template}

我也找不到任何文档。我收到同样的错误,说{@param ...}语法在V2中无效。然后,我发现soynode的示例(例如this one)使用了注释语法。有趣的是,这种新语法似乎根本不包含类型定义,而只是一个var名称。