Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there Child / Sub Templates Support? {{> myOtherTpl}} #51

Open
zeroasterisk opened this issue Nov 30, 2016 · 6 comments
Open

Is there Child / Sub Templates Support? {{> myOtherTpl}} #51

zeroasterisk opened this issue Nov 30, 2016 · 6 comments

Comments

@zeroasterisk
Copy link

Is there Child / Sub Templates Support? {{> myOtherTpl}}

How do I set that up?

@Data-Meister
Copy link

Data-Meister commented Dec 6, 2016

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.

@thebarty
Copy link

@zeroasterisk: Can you share which solution you have used? I'd love to have some infos on this 👍

@po-jo
Copy link

po-jo commented Feb 17, 2017

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 !

@po-jo
Copy link

po-jo commented Feb 17, 2017

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 !

@vany0114
Copy link

vany0114 commented Jul 5, 2017

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.

@vany0114
Copy link

vany0114 commented Jul 5, 2017

Forget it man, it was because I had the "template" tag into the child template, but in the server templates it doesn't necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants