Accessing custom collection variables within helpers

I have a custom collection defined as:

country: {
   link: '/country/{country}/index.html',
   template: 'layouts_blog/country.html'
}

Within a Middleman layout, the value of {country} is accessible as the variable ‘country’. However, I can’t find any way to get access to that variable from a method defined in a helper class, i.e. if I add:

module MyHelper
   def some_method()
       return country
   end
end

calling ‘some_method()’ from a layout just returns nil.

Which Middleman globals are accessible to helpers? It looks as if current_page and current_article are accessible, but I haven’t been able to find any way to get access to that ‘country’ variable (or other, similar variables) within a helper, short of passing it in explicitly.

You can make the method take a country?

like

module MyHelper
   def some_method( country)
       return country
   end
end

Thanks. I was actually trying to avoid passing arguments to the method. The methods I was writing are intended to compute titles, keywords, descriptions etc. for each page, and the goal was to be able to simplify my header layout so that I could just write:

<title><%= get_page_title() %></title>
<meta name="description" content="<%= get_page_description() %>" />
<meta name="keywords" content="<%= get_page_keywords() %>" />
<meta name="robots" content="<%= get_page_robots() %>" />

Having to pass arbitrary variables for each of the different collection types into the methods would complicate this.

For what it’s worth, I came up with a hack, in the form of a method:

def extract_identifier()
	begin
		result = current_page.path.split("/")[1]
		if result.nil?
			result = "unknown"
		end
	rescue StandardError => err
		puts "Error calling 'extract_identifier()'"
		result = "unknown"
	end
	return result
end

So for a page whose path is something like ‘/country/argentina/’, this will return ‘argentina’, which is what I wanted.