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



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

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

Instance Method Details

#+(other) ⇒ Object



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

def + other
  self.dup << other
end

#<<(obj) ⇒ Object



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

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



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

def concat(obj)
  self << obj
end

#documentObject Also known as: doc



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

def document
  self
end

#elementObject Also known as: e



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

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

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



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

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

#pushObject



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

alias_method 'push', 'concat'

#puts(string) ⇒ Object



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

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

#raw(string) ⇒ Object



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

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

#to_sObject



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

def to_s
  self
end

#to_strObject



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

def to_str
  self
end

#writeObject



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

alias_method 'write', 'concat'