terraform icon indicating copy to clipboard operation
terraform copied to clipboard

Support nested layout: layout with its own layout

Open echaozh opened this issue 12 years ago • 6 comments

Test is included.

Layout for layout is useful, and is supported in Jekyll. I refactored the layout finding code out and call it again in partial() before the first layout is rendered.

All tests are passing.

The earlier layout explicit set to false fix is included too. The code change in lib is moved to helpers/raw.js with the whole layout finding logic. The test is still where it was, though.

echaozh avatar Oct 09 '13 16:10 echaozh

Very interesting! This has definitely come up before, even the day before yesterday actually: https://twitter.com/axis12345678/status/387053584065757184

I’m a little unclear on how you actually use it, though. And did it make changes to how layout is used in the _data.json?

kennethormandy avatar Oct 09 '13 18:10 kennethormandy

It doesn't change how layout is used in _data.json. You just need to set a value to layout for a layout template. For demo usage, you can take a look at the added test case.

echaozh avatar Oct 10 '13 02:10 echaozh

Worth noting that Jade already supports nested layouts via extends, block, and prepend/append.

http://www.devthought.com/code/use-jade-blocks-not-layouts/ http://www.learnjade.com/tour/block-append-and-prepend/

edrex avatar Nov 16 '13 02:11 edrex

Any reason why this isn't in source yet? (For those of us not using Jade. ;)

cfjedimaster avatar Feb 13 '14 23:02 cfjedimaster

At least as far as I could determine, it overwrites the default behaviour of layout in a _data.json file. That said, we shouldn’t have left this unresolved, so apologies for that. You can accomplish this now using partial(), but there has definitely been a demand for some kind of nested layouts. We’ll either improve the documentation around an alternate method or take another look at this.

kennethormandy avatar Feb 13 '14 23:02 kennethormandy

Fair enough. I'm going to blog an example for EJS tomorrow. I'm assuming the thought is something like this (pseudo-code):

top level layout:

partial a header yield partial a footer

lower layout: partial the top header yield partial the top footer

On Thu, Feb 13, 2014 at 5:08 PM, Kenneth Ormandy [email protected]:

At least as far as I could determine, it overwrites the default behaviour of layout in a _data.json file. That said, we shouldn't have left this unresolved, so apologies for that. You can accomplish this now using partial(), but there has definitely been a demand for some kind of nested layouts. We'll either improve the documentation around an alternate method or take another look at this.

Reply to this email directly or view it on GitHubhttps://github.com/sintaxi/terraform/pull/14#issuecomment-35037826 .

Raymond Camden, Web Developer for Adobe

Email : [email protected] Blog : www.raymondcamden.com Twitter: cfjedimaster

cfjedimaster avatar Feb 13 '14 23:02 cfjedimaster