Skip to content

Instantly share code, notes, and snippets.

@lachlanhardy
Created March 10, 2009 03:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save lachlanhardy/76696 to your computer and use it in GitHub Desktop.
Save lachlanhardy/76696 to your computer and use it in GitHub Desktop.
# So this is in my controller:
@items = Dir.glob("views/*/*")
# Its contents look like this:
# views/controls/actions.haml
# views/controls/buttons.haml
# views/controls/formForge.haml
# views/controls/hide-actions.haml
# views/controls/index.haml
# views/controls/navigation.haml
# views/controls/tree.haml
# views/dialogs/browser.haml
# views/dialogs/dialogBox.haml
# My view contains this:
- if @items
- @items.each do |item|
- name = item.gsub(/views\/.+\/(.+).haml/, '\1')
- if name != "index"
%p do some stuff
# That worked fine until now, when I want to also exclude names that start with 'hide-'.
# Suggestions thus far (based on my limited cues) have not worked and looked something like these:
!@items.grep(/hide-.+/).empty?
@items.select{|x| !x.match(/hide-.+/)}
# And I started with something like
unless %w["index", /hide-.+/].include? name
# Any of all of my code above is certainly rubbish. Feel free to make suggestions to fix other stuff too ;)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment