Open zeroasterisk opened 7 years ago
This should work as you've written it. If not you can use a dynamic template.
However see this issue #52 - you must explicitly specify data context for dynamic templates. Perhaps you also need to explicitly specify data context for sub templates too.
@zeroasterisk: Can you share which solution you have used? I'd love to have some infos on this 👍
hi @zeroasterisk: same as @thebarty, It would be cool to know how you solve this stuff (have the same, tried with data context with no result :( ) Thanks !
It was a typo, {{> childTemplate}} inclusion works (don't forget to do a SSR.compileTemplate('chilTemplate', Assets.getText('childTemplate.html')) before). Sorry for the noise !
Hi @po-jo, Can you give me a little example, please?...it doesn't work for me. I have a child template inside the main template.
Server code:
SSR.compileTemplate('basicData', Assets.getText('contract/basicData.html'));
SSR.compileTemplate('main', Assets.getText('contract/main.html'));
var html_string = SSR.render('main', {
css: css,
contract: contract
});
Template code:
{{{getDocType}}}
<html>
<head>
<meta charset="utf-8">
<title>MVMCo</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<style type="text/css">
{{css}}
</style>
</head>
<body class="body-contract-report">
<h1>{{ contract.code }}</h1>
{{> basicData contract=contract }}
</body>
</html>
So I just render the "main" template and I expected that its child renders too, but it doesn't happen, only rendered the main template content.
Forget it man, it was because I had the "template" tag into the child template, but in the server templates it doesn't necessary.
Is there Child / Sub Templates Support?
{{> myOtherTpl}}
How do I set that up?