Class: Tagz::Namespace::Document

Inherits:
HTMLSafe
  • Object
show all
Defined in:
lib/tagz.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from HTMLSafe

#html_safe, #html_safe?

Class Method Details

.for(other) ⇒ Object



246
247
248
# File 'lib/tagz.rb', line 246

def Document.for(other)
  Document === other ? other : Document.new(other.to_s)
end

Instance Method Details

#+(other) ⇒ Object



290
291
292
# File 'lib/tagz.rb', line 290

def + other
  self.dup << other
end

#<<(obj) ⇒ Object



258
259
260
261
262
263
264
265
266
# File 'lib/tagz.rb', line 258

def << obj
  if obj.respond_to?(:html_safe?) and obj.html_safe?
    super obj.to_s
  else
    super Tagz.escape_content(obj)
  end

  self
end

#concat(obj) ⇒ Object



268
269
270
# File 'lib/tagz.rb', line 268

def concat(obj)
  self << obj
end

#documentObject Also known as: doc



285
286
287
# File 'lib/tagz.rb', line 285

def document
  self
end

#elementObject Also known as: e



250
251
252
# File 'lib/tagz.rb', line 250

def element
  Tagz.element.new(*a, &b)
end

#escape(string) ⇒ Object Also known as: h



272
273
274
# File 'lib/tagz.rb', line 272

def escape(string)
  Tagz.escape(string)
end

#pushObject



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

alias_method 'push', 'concat'

#puts(string) ⇒ Object



277
278
279
# File 'lib/tagz.rb', line 277

def puts(string)
  write "#{ string }\n"
end

#raw(string) ⇒ Object



281
282
283
# File 'lib/tagz.rb', line 281

def raw(string)
  push Document.for(string)
end

#to_sObject



294
295
296
# File 'lib/tagz.rb', line 294

def to_s
  self
end

#to_strObject



298
299
300
# File 'lib/tagz.rb', line 298

def to_str
  self
end

#writeObject



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

alias_method 'write', 'concat'