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



242
243
244
# File 'lib/tagz.rb', line 242

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

Instance Method Details

#+(other) ⇒ Object



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

def + other
  self.dup << other
end

#<<(obj) ⇒ Object



254
255
256
257
258
259
260
261
262
# File 'lib/tagz.rb', line 254

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



264
265
266
# File 'lib/tagz.rb', line 264

def concat(obj)
  self << obj
end

#documentObject Also known as: doc



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

def document
  self
end

#elementObject Also known as: e



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

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

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



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

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

#pushObject



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

alias_method 'push', 'concat'

#puts(string) ⇒ Object



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

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

#raw(string) ⇒ Object



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

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

#to_sObject



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

def to_s
  self
end

#to_strObject



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

def to_str
  self
end

#writeObject



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

alias_method 'write', 'concat'