来自多个大豆文件的封闭模板

问题描述 投票:2回答:1

我有一个名为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}

这可能吗?

google-closure google-closure-templates
1个回答
1
投票

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

compile all templates simultaneously

java -jar SoyToJsSrcCompiler.jar --srcs templates.soy,selectField.soy
© www.soinside.com 2019 - 2024. All rights reserved.