Module: Sinatra::JstPages::Helpers
- Defined in:
- lib/sinatra/jstpages.rb
Instance Method Summary collapse
-
#jst_files(options = {}) ⇒ Object
Returns a list of JST files.
Instance Method Details
#jst_files(options = {}) ⇒ Object
Returns a list of JST files.
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/sinatra/jstpages.rb', line 115 def jst_files( = {}) # Tuples of [ name, Engine instance ] root = [:root] || settings.views tuples = Dir.chdir(root) { Dir["**/*.jst*"].map { |fn| name = fn.match(%r{^(.*)\.jst})[1] ext = fn.match(%r{\.([^\.]*)$})[1] engine = JstPages.mappings[ext] [ name, engine.new(name, File.join(root, fn)) ] if engine }.compact } Hash[*tuples.flatten] end |