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

Included dt file not override-able by inherited template #14

Closed
rjframe opened this issue Jan 21, 2017 · 0 comments
Closed

Included dt file not override-able by inherited template #14

rjframe opened this issue Jan 21, 2017 · 0 comments

Comments

@rjframe
Copy link

rjframe commented Jan 21, 2017

I have the following file setup, using diet-ng with vibe.d (WebInterface)(the original diet implementation also has this issue):

layout.dt provides my page structure.
leftnav.dt is included by layout.dt for navigation.
And my pages, which extend layout.dt and attempt to override a block in leftnav.dt. I would expect that since the block is included by layout.dt any file that extends layout.dt would be able to override it, but my attempts to do so are ignored - the overriding block doesn't make it into the html at all.

If I actually copy the contents of leftnav.dt into layout.dt everything works as expected. According to the diet documentation include is effectively a copy-paste, but it isn't quite working that way.

I could also work around it by passing data to the render function (as adding "active" to the li class is all I really care about here), but would prefer not to do that.

//- layout.dt
doctype html
html(lang="en")
	head
		block head
			title Diet Include Test
	body
		div
			//- I'll want to modify blocks in leftnav in child templates.
			include leftnav
		div.main
		block content
				p Content goes here.
//- leftnav.dt
ul
	//- These blocks should (but don't) let me adjust each individual item in other templates.
	block navIndex
		li
			a(href="/") Home
	block navPage2
		li
			a(href="/pagetwo") Not Home
//- index.dt
extends layout
//- I expect this block to override the block in layout.dt via the include, but is ignored.
block navIndex
	li
		a(class="active", href="/") Home Override
block content
	h1 Hello!
	p "Home" should say "Home Override".
//- pagetwo.dt is much the same as index
extends layout
block head
	title Diet Test - Page Two
block navPage2
	li
		a(class="active", href="/pagetwo") Page Two
block content
	h1 The second page.
	p "Not Home" should say "Page Two".
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

1 participant