Closed joefiorini closed 11 years ago
haha you do like nesting things :smile: (love it)
I'll admit I hadn't thought of this use case and I'm not surprised the code isn't quite keeping up here - let me have a look at the source and I'll see if I can get this particular approach working.
for reference the failing test is in this commit: joefiorini/cadenza@a8ba29801e0d13168e418747855c795febc2532a
I read a thread on the django issue tracker where someone asked about this very issue. They basically said that that's just the way nested blocks work and you have to deal with it.
Either which way, I actually changed the markup so that the nesting wasn't necessary. A much better, if less intuitive solution IMO.
Makes me wonder if that's the typical case; maybe a need for this kind of nesting indicates a larger problem in your markup?
well it is a bit "out there" and maybe not the best way to use liquid/cadenza/django as they are intended to be template languages with simplicity such that non-programmers (like designers) would be able to figure it out.
That said however I don't think "this is the way things are, deal with it" is an appropriate answer, the ability to use complex stuff like this should be available since the behaviour is pretty much undefined right now.
I don't want Cadenza to handcuff you from doing complex layouts, in fact I'd love to have it as an option replace Rails/Sinatra views with it because it intentionally prevents you from executing code in your views that you shouldn't. I think experts would appreciate things like this.
I'm wondering if this is an indication that nested blocks should work like namespacing in other languages, consider this ruby example:
class Foo
class Bar
end
end
You don't end up with two classes Foo
and Bar
, you end up with two classes Foo
and Foo::Bar
Perhaps Cadenza should function in a similar fashion?
{% block layout %}
{% block header %}
<header></header>
{% endblock %}
{% block content %}{% endblock %}
{% endblock %}
Perhaps this should give you three named blocks: layout
, layout::header
and layout::content
instead of how it currently works (three blocks named layout
, header
, content
)
Makes some sense. Would the namespace be something the user would have to refer to it by or could they just say "header" instead of having to say "layout.header"?
Sent from my mobile device
On Jan 30, 2013, at 10:44 AM, William Howard notifications@github.com wrote:
well it is a bit "out there" and maybe not the best way to use liquid/cadenza/django as they are intended to be template languages with simplicity such that non-programmers (like designers) would be able to figure it out.
That said however I don't think "this is the way things are, deal with it" is an appropriate answer, the ability to use complex stuff like this should be available since the behaviour is pretty much undefined right now.
I don't want Cadenza to handcuff you from doing complex layouts, in fact I'd love to have it as an option replace Rails/Sinatra views with it because it intentionally prevents you from executing code in your views that you shouldn't. I think experts would appreciate things like this.
I'm wondering if this is an indication that nested blocks should work like namespacing in other languages, consider this ruby example:
class Foo class Bar end end You don't end up with two classes Foo and Bar, you end up with two classes Foo and Foo::Bar
Perhaps Cadenza should function in a similar fashion?
{% block layout %} {% block header %}
{% endblock %} {% block content %}{% endblock %} {% endblock %} Perhaps this should give you three named blocks: layout, layout::header and layout::content instead of how it currently works (three blocks named layout, header, content)
— Reply to this email directly or view it on GitHub.
I'm hoping not, unless you're doing crazy hacky stuff that is.
Inside the template the parser should be able to infer the namespace by tracking the block nesting On Jan 30, 2013 3:03 PM, "Joe Fiorini" notifications@github.com wrote:
Makes some sense. Would the namespace be something the user would have to refer to it by or could they just say "header" instead of having to say "layout.header"?
Sent from my mobile device
On Jan 30, 2013, at 10:44 AM, William Howard notifications@github.com wrote:
well it is a bit "out there" and maybe not the best way to use liquid/cadenza/django as they are intended to be template languages with simplicity such that non-programmers (like designers) would be able to figure it out.
That said however I don't think "this is the way things are, deal with it" is an appropriate answer, the ability to use complex stuff like this should be available since the behaviour is pretty much undefined right now.
I don't want Cadenza to handcuff you from doing complex layouts, in fact I'd love to have it as an option replace Rails/Sinatra views with it because it intentionally prevents you from executing code in your views that you shouldn't. I think experts would appreciate things like this.
I'm wondering if this is an indication that nested blocks should work like namespacing in other languages, consider this ruby example:
class Foo class Bar end end You don't end up with two classes Foo and Bar, you end up with two classes Foo and Foo::Bar
Perhaps Cadenza should function in a similar fashion?
{% block layout %} {% block header %}
{% endblock %} {% block content %}{% endblock %} {% endblock %} Perhaps this should give you three named blocks: layout, layout::header and layout::content instead of how it currently works (three blocks named layout, header, content)
— Reply to this email directly or view it on GitHub.
— Reply to this email directly or view it on GitHubhttps://github.com/whoward/cadenza/issues/17#issuecomment-12909397.
success! I've got your use case working, turns out it was a pretty simple bug
the namespacing issue is probably a separate one, will have to tackle that one later
Nice, thanks! Great work!
On Thu, Feb 7, 2013 at 9:36 PM, William Howard notifications@github.comwrote:
success! I've got your use case working, turns out it was a pretty simple bug
the namespacing issue is probably a separate one, will have to tackle that one later
— Reply to this email directly or view it on GitHubhttps://github.com/whoward/cadenza/issues/17#issuecomment-13274242.
Hey there,
I'm finally getting around to setting up a slightly advanced layout in Cadenza. Calling
{{super}}
isn't working quite as I'm expecting. I've created a failing test case and pushed it to my fork of this project on thenested-super
branch.Here's my setup:
layout.html.cadenza
super.html.cadenza
super.html
– expected outputsuper.html
– actual outputSo I'm expecting that including the
header
block and callingsuper
should get the block from the layout.Is this a bug or am doing something wrong?
Thanks!