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

Already on GitHub? Sign in to your account

block append / prepend #355

Closed
hugovincent opened this Issue Sep 30, 2011 · 9 comments

Comments

Projects
None yet
3 participants

A common use of inheritance for templating involves overriding a block multiple times and expecting each override to be concatenated together. I think this should be supported in Jade. Example follows:

template.jade:

html
    head
        title test
        script(src='whatever')
        block extra_scripts
    body
        include nav_bar
        block content

mypage.jade:

extends template
block extra_scripts
    script(src='my_awesome_script')
block content
    p Hello world

nav_bar.jade:

block extra_scripts
    script(src='another_script')
ul
    li Home
    li About

The problem is twofold; first blocks don't seem to behave properly across include boundaries, and second, in this example, extra_scripts block should contain both scripts, but doesn't. Am I just using it wrong or is this an actual problem?

Contributor

tj commented Sep 30, 2011

hmm I had planned on adding either block append scripts\n stuff or append scripts\n stuff which to me seems more explicit, I wasn't aware that django (if that's what you're referring to) concatenates, to me that seems to be more of a gotcha

block append scripts sounds perfect (explicit is better than implicit, you're right). Any idea when this addition might land in the repo?

Contributor

tj commented Sep 30, 2011

i'll probably have time for it some time next week

Contributor

jgallen23 commented Nov 13, 2011

any update on this ticket? I'd like to do something similar

Contributor

tj commented Dec 2, 2011

re-titled so it stands out later :D

@tj tj closed this in 08687c0 Dec 2, 2011

Contributor

tj commented Dec 2, 2011

with inheritance it's a little weird, since you're prepending / appending to the parent block, might end up causing some gotchas

Contributor

jgallen23 commented Dec 2, 2011

this is awesome! any idea on when this will be officially released to npm?

Contributor

tj commented Dec 2, 2011

right meow: 0.19.0

Contributor

jgallen23 commented Dec 2, 2011

hot damn! thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment