Skip to content

Instantly share code, notes, and snippets.

@phantomwhale
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phantomwhale/7c1b0a8a119fce7d24bf to your computer and use it in GitHub Desktop.
Save phantomwhale/7c1b0a8a119fce7d24bf to your computer and use it in GitHub Desktop.
High Voltage Pages Helper
module HighVoltagePagesHelper
class << self
include Rails.application.routes.url_helpers
end
module_function
def static_pages
Dir.entries(Rails.root.join('app', 'views', 'pages')).inject([]) do |pages, file|
matches = file.match(/\.html\.[a-z]+$/)
next pages if matches.nil?
filename = file.sub(matches[0], "")
title = filename.titleize
path = page_path(filename)
pages.push(title: title, path: path)
end
end
end
@phantomwhale
Copy link
Author

Helper module for obtaining all High Voltage static pages

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment