Web2py's tree structured layout seems to fall short in one area.  I do not 
know if this is a bug, or if it is "working as designed"...

I'm trying  to bring order to the chaos that is my layout.html file.  I 
wanted to break it into reasonable sections so I could manage each 
separately instead of always dealing with a big bag 'o stuff.

To that end, I created a minimal layout.html file that uses "include" 
directives for header, footer, and body:

<!DOCTYPE html>
<!-- 
paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
<!--[if lt IE 7]><html class="ie ie6 ie-lte9 ie-lte8 ie-lte7 no-js" 
lang="{{=T.accepted_language or 'en'}}"> <![endif]-->
<!--[if IE 7]><html class="ie ie7 ie-lte9 ie-lte8 ie-lte7 no-js" 
lang="{{=T.accepted_language or 'en'}}"> <![endif]-->
<!--[if IE 8]><html class="ie ie8 ie-lte9 ie-lte8 no-js" 
lang="{{=T.accepted_language or 'en'}}"> <![endif]-->
<!--[if IE 9]><html class="ie9 ie-lte9 no-js" lang="{{=T.accepted_language 
or 'en'}}"> <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--> <html class="no-js" 
lang="{{=T.accepted_language or 'en'}}"> <!--<![endif]-->

{{include "include_header.html"}}

<body>

{{include "include_navigation.html"}}

<div id="main_container">

{{include "include_dashboard.html"}}

  <div class="page-content">
    <div class="row-fluid">
      <div class="span12">
      <!-- PAGE CONTENT BEGINS -->
        {{block center}}
        {{include}}
        {{end}}
      <!-- PAGE CONTENT ENDS -->
      </div><!-- /.span -->
    </div><!-- /.row-fluid -->
  </div><!-- /.page-content -->
  
</div><!-- /.main-content -->

{{include "include_devtools.html"}}

{{include "include_footer.html"}}


Then, in the file include_header.html, for example, I would provide a place 
for blocks so the layout could be extended:

<head>
  ... bunch of header related stuff goes here...
  {{block head}} {{end}}
</head>


Unsurprisingly, this works fine -- but only to a point.  When I declare a 
{{block head}}{{end}} block on my page, it gets substituted in the header 
as expected, but it ALSO appears on the page in the "content" area of the 
{{include}} directive on the top layout.html page.  That is, it appears 
twice in my page!

Apart from the wasted bandwidth (which with caching isn't a big deal) the 
main problem is that many things don't like to be loaded twice.  My jQuery 
DataTables stuff, for instance, complains loudly about being initialized 
twice.

So am I using the tools beyond their capability?  Or is this just a minor 
bug that is easily corrected?

-- Joe

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to