I'm pretty new to all this, and--forgive me--must be missing something
very basic here about partials in staticmatic.
I have a site each of whose pages starts with this HAML:
======================
!!! Strict
%html
-# current page reference (StaticMaitc)
- current = current_page #
-# current page name stripped of path and ".html"
- @tag = File.basename(current, ".html")
-# extract page name's first character: x_pagename; use that for
tertiary menu; irrelevant if no tertiary
- @sub = @tag[0,1]
=partial('head-partial', :locals => { :location => @tag })
%body#page
=partial('topnav-partial', :locals => { :location => @tag })
=partial('logonav-partial', :locals => { :location => @tag })
=partial('banner-partial', :locals => { :location => @tag })
.element_wrapper
.side
.main
%h2 Purpose, Background, History of the Society of New Concord
%p
======================
All this works fine, but to DRY things up I thought I could roll all
this repetitive portion of the HAML into another partial, like so:
======================
!!! Strict
%html
=partial('topmatter-partial')
.element_wrapper
.side
.main
%h2 Purpose, Background, History of the Society of New Concord
%p
======================
and the partials are listed here:
topmatter-partial:
======================
-# current page reference (StaticMaitc)
- current = current_page #
-# current page name stripped of path and ".html"
- @tag = File.basename(current, ".html")
-# extract page name's first character: x_pagename; use that for
tertiary menu; irrelevant if no tertiary
- @sub = @tag[0,1]
=partial('head-partial', :locals => { :location => @tag })
%body#page
=partial('topnav-partial', :locals => { :location => @tag })
=partial('logonav-partial', :locals => { :location => @tag })
=partial('banner-partial', :locals => { :location => @tag })
======================
head-partial:
======================
%head
- snc = 'The Society of New Concord'
- info = YAML.load_file("src/helpers/page_particulars.yaml")
- particulars = info[location]
- title = particulars["name"]
-# if title
-# if true
-# totaltitle = "#{snc} - #{title}"
-# else
-# totaltitle = snc
- totaltitle = "#{snc} - #{title}"
%title=totaltitle
%meta{:name => "language", :content => "en"}/
%meta{:name => "description", :content => "The Society of New
Concord; an organization for the hamlet of New Concord to promote
historical, social and civic goals, near Chatham, New York"}/
%meta{:name => "keywords", :content => "New Concord, Chatham,
Society, New York, "}/
%meta{:name => "robots", :content => "ALL"}/
%meta{:name => "author", :content => "Richard H.S.Karpinski
http://groups.google.com/group/SocietyOfNewConcord"}/
%meta{:name => "copyright", :content => "© 2009 the Society
of New Concord"}/
%link{:href => "favicon.ico", :rel => "shortcut icon", :type =>
"image/png"}/
%link{:href => "favicon.ico", :rel => "icon", :type => "image/png"}/
%link{:href => "stylesheets/screen.css", :media => "screen,
projection", :rel => "stylesheet", :type => "text/css"}/
%link{:href => "stylesheets/print.css", :media => "print", :rel =>
"stylesheet", :type => "text/css"}/
%link{:href => "stylesheets/ie.css", :media => "screen,
projection", :rel => "stylesheet", :type => "text/css"}/
/[if IE] <link rel="stylesheet" type="text/css" href="ie.css" />
======================
topnav-partial:
======================
.topnav_wrapper
.topnav
- info = YAML.load_file("src/helpers/top_menu.yaml")
=list_of(info) do |h|
- name = h.keys.first
- hash = h[name]
-# need to test current page somehow agains the hash key name
- idval = location == name ? "current" : false
-# sets "id" of %a unless "idval" is false
-# in that case "id" is not set at all
%a{:href => hash["ref"], :title => hash["tooltip"], :id =>
idval}
= hash["item"]
%span= hash["popup"]
======================
logonav-partial:
======================
.logonav_wrapper
#logo_pale
%a{:href => "index.html", :title => "SNC Homepage"} the Society of
#logo_bright
%a{:href => "index.html", :title => "SNC Homepage"} New Concord
.nav
- info = YAML.load_file("src/helpers/main_menu.yaml")
=list_of(info) do |h|
- name = h.keys.first
- hash = h[name]
-# need to test current page somehow agains the hash key name
- idval = location == name ? "current" : false
-# sets "id" of %a unless "idval" is false
-# in that case "id" is not set at all
%a{:href => hash["ref"], :title => hash["tooltip"], :id =>
idval}
= hash["item"]
%span= hash["popup"]
======================
banner-partial:
======================
.banner_wrapper
.banner
- info = YAML.load_file("src/helpers/page_particulars.yaml")
- particulars = info[location]
%h1= particulars["banner"]
.breadcrumbs breadcrumbs
======================
I've tinkered around a bit with indentation levels, but couldn't get
this to work. The error message is:
======================
StaticMatic::TemplateError
2: - current = current_page #
3: -# current page name stripped of path and ".html"
4: - @tag = File.basename(current, ".html")
5: -# extract page name's first character: x_pagename; use that for
tertiary menu; irrelevant if no tertiary
6: - @sub = @tag[0,1]
7: =partial('head-partial', :locals => { :location => @tag })
8: %body#page
======================
Don't know what "StaticMatic::TemplateError" means.
Am I simply barking up the wrong tree, or am I stupidly missing
something basic/obvious?
Any help would be greatly appreciated.
Thanks.
--RK