From ea3067ff36c3beba69f4d788949b36939bb01e26 Mon Sep 17 00:00:00 2001 From: Miles Gould Date: Tue, 18 Sep 2012 18:52:37 +0100 Subject: [PATCH] Replace most of the HTML-in-HAML - We do this by moving code between files such that every tag starts and ends within a single file. This seems like a good invariant to maintain from a robustness point-of-view. - One consequence is that I had to split _header into _meta (metadata - the HTML head tag) and _header (the visible page header). These probably aren't the best names. - I've left some HTML in _meta, on the grounds that it maintains the file-contains-whole-tag invariant and the HTML code is fractionally shorter than the HAML required to generate it. --- app/views/layouts/_footer.html.haml | 6 ------ app/views/layouts/_header.html.haml | 16 ---------------- app/views/layouts/_meta.html.haml | 10 ++++++++++ app/views/layouts/application.html.haml | 23 ++++++++++++++--------- 4 files changed, 24 insertions(+), 31 deletions(-) create mode 100644 app/views/layouts/_meta.html.haml diff --git a/app/views/layouts/_footer.html.haml b/app/views/layouts/_footer.html.haml index a92d8777c..5e728baaf 100644 --- a/app/views/layouts/_footer.html.haml +++ b/app/views/layouts/_footer.html.haml @@ -1,6 +1,3 @@ - -- # There are some tags here, such as these close div tags and the close body and html tags below, which were opened in the header fragment. HAML can't handle this, so they're done in HTML instead. - .row .ten.columns %ul.link-list @@ -14,6 +11,3 @@ = link_to "Mailing list", "http://lists.growstuff.org/mailman/listinfo/discuss" %li = link_to "Community Guidelines", "https://github.com/Growstuff/policy/blob/master/community-guidelines.md" - - - diff --git a/app/views/layouts/_header.html.haml b/app/views/layouts/_header.html.haml index 0ed4e4aa2..ef413ee18 100644 --- a/app/views/layouts/_header.html.haml +++ b/app/views/layouts/_header.html.haml @@ -1,18 +1,3 @@ - -- # There are some tags here, such as html, body, etc, which are opened in this file and closed in the footer fragment. HAML can't handle this, so they're left as HTML. If you were wondering. - -%head - - - - %title - = content_for?(:title) ? yield(:title) : "Growstuff" - = stylesheet_link_tag "application", :media => "all" - = javascript_include_tag "application" - = csrf_meta_tags - - - .row .ten.columns - if user_signed_in? @@ -34,4 +19,3 @@ %h1 = link_to('Growstuff', root_path) -
diff --git a/app/views/layouts/_meta.html.haml b/app/views/layouts/_meta.html.haml new file mode 100644 index 000000000..89ca1c3d8 --- /dev/null +++ b/app/views/layouts/_meta.html.haml @@ -0,0 +1,10 @@ +%head + + + + %title + = content_for?(:title) ? yield(:title) : "Growstuff" + = stylesheet_link_tag "application", :media => "all" + = javascript_include_tag "application" + = csrf_meta_tags + diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 119cb0e26..01c9e37ad 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -1,9 +1,14 @@ -= render :partial => "layouts/header" -- if notice - %p.notice - = notice -- if alert - %p.alert - = alert -= yield -= render :partial => "layouts/footer" +%html + = render :partial => "layouts/meta" + %body + = render :partial => "layouts/header" + .row + .ten.columns + - if notice + %p.notice + = notice + - if alert + %p.alert + = alert + = yield + = render :partial => "layouts/footer"