Skip to content

Instantly share code, notes, and snippets.

@slowernet
Created August 26, 2008 05:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save slowernet/7218 to your computer and use it in GitHub Desktop.
Save slowernet/7218 to your computer and use it in GitHub Desktop.
module Merb
module GlobalHelpers
def include_templates
rv = '<div style="display: none;" class="jqt-templates">'
rv += glob_dir("#{Merb.root}/app/views/shared").join
rv += glob_dir("#{Merb.root}/app/views/#{controller_name.downcase}").join
rv + '</div>'
end
private
def glob_dir(dir)
Dir.glob(File.join(dir, "*.jqt")).map do |f|
"<div class='jqt-template' id='#{File.basename(dir)}-#{File.basename(f, '.jqt').downcase.sub(/[^a-z]/,'')}'>#{File.read(f)}</div>"
end
end
end
end
$('.jqt-templates .jqt-template').each(function(t) { ... });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment