【问题标题】:Closure templates from multiple soy files来自多个大豆文件的闭包模板
【发布时间】:2014-07-16 18:02:05
【问题描述】:

我有一个名为templates.soy 的模板,我希望能够从单独的文件中调用模板(希望不时以编程方式覆盖该文件)。我可以在同一个文件中调用模板。目前我有:

templates.soy

​​>
{namespace plugin.example}

/**
 * Template for the build
 */
{template .anthill}
<html>
    <head>
        ...
    <body>
        <h2>My Form</h2>
        <br />
        {call .form /}  //This works
        {call random.me.moreFields /}  //This throws an error "Attempting to render undefined template 'random.me.moreFields'
    </body>
</html>
{/template}

/**
 * Form info
 */
{template .form}
    //custom html form stuff
{/template}

selectField.soy

​​>
{namespace random.me}
/**
 * Testing more soy files
 */
{template .moreFields}
   //custom html stuff
{/template}

这可能吗?

【问题讨论】:

  • 是的,你可以。但是,我有点惊讶您想以编程方式生成大豆模板。 Soy 本身就是一种元语言,编译成 JavaScript 或 java。

标签: google-closure google-closure-templates


【解决方案1】:

是的,你可以。每个组件或页面有一个文件甚至是最佳实践。

只需compile all templates simultaneously

java -jar SoyToJsSrcCompiler.jar --srcs templates.soy,selectField.soy

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-08
    • 2016-04-13
    • 2015-01-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多