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.
This commit is contained in:
Miles Gould
2012-09-18 18:52:37 +01:00
parent a959d491e8
commit ea3067ff36
4 changed files with 24 additions and 31 deletions

View File

@@ -1,6 +1,3 @@
</div></div>
- # 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"
</body>
</html>

View File

@@ -1,18 +1,3 @@
<html>
- # 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
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href='http://fonts.googleapis.com/css?family=Sevillana' rel='stylesheet' type='text/css'>
%title
= content_for?(:title) ? yield(:title) : "Growstuff"
= stylesheet_link_tag "application", :media => "all"
= javascript_include_tag "application"
= csrf_meta_tags
<body>
.row
.ten.columns
- if user_signed_in?
@@ -34,4 +19,3 @@
%h1
= link_to('Growstuff', root_path)
<div class="row"><div class="ten columns">

View File

@@ -0,0 +1,10 @@
%head
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link href='http://fonts.googleapis.com/css?family=Sevillana' rel='stylesheet' type='text/css'>
%title
= content_for?(:title) ? yield(:title) : "Growstuff"
= stylesheet_link_tag "application", :media => "all"
= javascript_include_tag "application"
= csrf_meta_tags

View File

@@ -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"