Skip to content

Instantly share code, notes, and snippets.

@phantomwhale
Last active August 29, 2015 14:18
Show Gist options
  • Save phantomwhale/7c1b0a8a119fce7d24bf to your computer and use it in GitHub Desktop.
Save phantomwhale/7c1b0a8a119fce7d24bf to your computer and use it in GitHub Desktop.

Revisions

  1. phantomwhale revised this gist Apr 2, 2015. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion high_voltage_pages_helper.rb
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,9 @@ class << self
    include Rails.application.routes.url_helpers
    end

    def self.static_pages
    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?
  2. phantomwhale created this gist Apr 2, 2015.
    18 changes: 18 additions & 0 deletions high_voltage_pages_helper.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    module HighVoltagePagesHelper
    class << self
    include Rails.application.routes.url_helpers
    end

    def self.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