Module: Tagz

Included in:
Globally
Defined in:
lib/tagz.rb

Defined Under Namespace

Modules: Globally Classes: Element, Fragment

Constant Summary collapse

VERSION =
[
  Tagz::VERSION_MAJOR = 4,
  Tagz::VERSION_MINOR = 2,
  Tagz::VERSION_TEENY = 0 
].join('.')

Class Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(m, *a, &b) ⇒ Object (private)



187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
# File 'lib/tagz.rb', line 187

def method_missing m, *a, &b
  if not Globally === self
    unless defined?(@tagz) and @tagz
      begin
        super
      ensure
        $!.set_backtrace caller(skip=1) if $!
      end
    end
  end
  
  case m.to_s
    when %r/^(.*[^_])_(!)?$/o
      m, bang = $1, $2
      b ||= lambda{} if bang
      tagz{ tagz__(m, *a, &b) }
    when %r/^_([^_].*)$/o
      m = $1 
      tagz{ __tagz(m, *a, &b) }
    when 'e'
      Element.new(*a, &b)
    when '__'
      tagz{ tagz << "\n" }
    else
      begin
        super
      ensure
        $!.set_backtrace caller(skip=1) if $!
      end
  end
end

Class Method Details

.<<(other) ⇒ Object



88
89
90
91
# File 'lib/tagz.rb', line 88

def Tagz.<< other
  Tagz.tagz << other
  self
end

.escapeHTML(string) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/tagz.rb', line 13

def Tagz.escapeHTML string
  string = string.to_s.dup
  string.gsub!(%r/&/n, '&amp;')
  string.gsub!(%r/\"/n, '&quot;')
  string.gsub!(%r/>/n, '&gt;')
  string.gsub!(%r/</n, '&lt;')
  string
end

.export(*methods) ⇒ Object



82
83
84
85
86
# File 'lib/tagz.rb', line 82

def Tagz.export *methods 
  methods.flatten.compact.uniq.each do |m|
    module_function m
  end
end

.globallyObject



101
102
103
# File 'lib/tagz.rb', line 101

def Tagz.globally
  Globally
end

.versionObject



10
# File 'lib/tagz.rb', line 10

def Tagz.version() Tagz::VERSION end