Sha256: ce9825c623f72305a9d1713230e2c3bb111f988b652a2cabb7decb919b0e6198
Contents?: true
Size: 1.3 KB
Versions: 24
Compression:
Stored size: 1.3 KB
Contents
# frozen_string_literal: true require "pages_core/templates/block_configuration" require "pages_core/templates/configuration_proxy" require "pages_core/templates/configuration_handler" require "pages_core/templates/configuration" require "pages_core/templates/controller_actions" require "pages_core/templates/template_configuration" module PagesCore module Templates class << self def names @names ||= find_all_templates end private def template_paths [ PagesCore.plugin_root.join("app/views/pages/templates"), Rails.root.join("app/views/pages/templates") ] end def template_files template_paths .select { |dir| File.exist?(dir) } .flat_map { |dir| template_files_in_dir(dir) } .uniq .compact .sort .map { |f| f.gsub(/\.[\w.]+$/, "") } end def template_files_in_dir(dir) Dir.entries(dir).select { |f| template_file?(f, dir) } end def template_file?(file, dir) File.file?(File.join(dir, file)) && !file.match(/^_/) end def find_all_templates if template_files.include?("index") ["index"] + (template_files - ["index"]) else template_files end end end end end
Version data entries
24 entries across 24 versions & 1 rubygems