I have a template called templates.soy
and I would like to be able to call a template from a separate file (would like to overwrite that file programmatically from time to time). I can call a template within the same file. Currently I have:
{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}
{namespace random.me}
/**
* Testing more soy files
*/
{template .moreFields}
//custom html stuff
{/template}
Is this possible?
Yes, you can. It's even the best practice to have one file per component or page.
Just compile all templates simultaneously .
java -jar SoyToJsSrcCompiler.jar --srcs templates.soy,selectField.soy
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.