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

Example project with template nesting #121

Open
adam-lynch opened this issue Oct 15, 2014 · 1 comment
Open

Example project with template nesting #121

adam-lynch opened this issue Oct 15, 2014 · 1 comment

Comments

@adam-lynch
Copy link

I like the idea of plates but I'm not sure how it would work in a project with a lot of partial templates that have to include other templates. Note: I'd be thinking of using it on its own, not as part of flatiron.

Let's say there's a template which has an element which contains another partial template which includes more, etc. Imagine there are a lot of top-level templates like this. How would someone manage this and the mappings needed? Each top-level template would need a specific permutation of mappings & partial injections applied to it. Or in other words, each partial would need its own mapping but this would be have to be managed somehow.

Also, each template may of course use different names for vars. So if one template includes another, the first mapping needs to converted into the second.


With a DSL (let's say with swig), you kind of get this for free; for example:

a.swig.html

<div>
<p>{{ hello }}</p>
{% include './b.swig.html' with { world: hello } only %}
</div>

b.swig.html

<p>{{ world }}</p>

And then rendering a.swig.html with {hello: 'a'} will give :

<div>
<p>a</p>
<p>a</p>
</div>

Are there any example projects out there that would show how this should be done?

@serapath
Copy link

I am also interested in this.
Plates exports a method "partial" and "append" which are equivalent and which do sub templates.
Still, i'm sometimes confused what would be the best way to nest stuff, because there seem to be several ways, one which seems to not need "partial" and "append" at all, but i'm not sure. :-)

I'm planning of using "plates" in my own templating language which should support data binding on top.

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

2 participants