Last active
August 29, 2015 14:18
-
-
Save phantomwhale/7c1b0a8a119fce7d24bf to your computer and use it in GitHub Desktop.
High Voltage Pages Helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Helper module for obtaining all High Voltage static pages