module RubyHtmlApp::Helpers
Public Instance Methods
asset_data_uri(path)
click to toggle source
# File lib/rubyhtmlapp/helpers.rb, line 19 def asset_data_uri(path) asset = @sprocket_env[path] Sprockets::Context.new(@sprocket_env, asset.logical_path, asset.pathname).asset_data_uri(path) end
find_f(path, pattern)
click to toggle source
# File lib/rubyhtmlapp/helpers.rb, line 24 def find_f(path, pattern) Find.find(path) do |f| return f if File.basename(f).match(pattern) end nil end
find_f_each(path, pattern) { |f| ... }
click to toggle source
# File lib/rubyhtmlapp/helpers.rb, line 31 def find_f_each(path, pattern) Find.find(path) do |f| yield(f) if File.basename(f).match(pattern) end end
include_dir(dir, locals={}, &block)
click to toggle source
# File lib/rubyhtmlapp/helpers.rb, line 11 def include_dir(dir, locals={}, &block) html = "" find_f_each(File.join(@partial_path, dir), /[0-9a-z]{1}\.html[a-z\.0-9]*$/i) do |f| html.concat(Tilt.new(f).render(self, locals, &block)) end return html end
render(partial, locals={}, &block)
click to toggle source
# File lib/rubyhtmlapp/helpers.rb, line 7 def render(partial, locals={}, &block) Tilt.new(find_f(@partial_path, /_#{partial}.html[a-z\.0-9]*$/i)).render(self, locals, &block) end