lachlanhardy (owner)

Forks

Revisions

gist: 76696 Download_button fork
public
Public Clone URL: git://gist.github.com/76696.git
Embed All Files: show embed
Ruby #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# 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 ;)