Sha256: a24eba24fc39cbfc4b95f7bdc1fa5ecaf29c3cb3290f79d9dd8af28f26ff6caa

Contents?: true

Size: 638 Bytes

Versions: 2

Compression:

Stored size: 638 Bytes

Contents

# p __FILE__

module HTMLHelper

  def wrapped(str, *tags)   # helper
    open, close = open_close_tags(*tags)
    open + str + close
  end

  def wrapped!(str, tag, **extras)    # helper
    open, close = open_close_tags(tag)
    extras.each_pair do |name, value|
      open.sub!(">", " #{name}='#{value}'>")
    end
    open + str + close
  end

  def wrap(*tags)     # helper
    open, close = open_close_tags(*tags)
    _out open
    yield
    _out close
  end

  def open_close_tags(*tags)
    open, close = "", ""
    tags.each do |tag|
      open << "<#{tag}>"
      close.prepend("</#{tag}>")
    end
    [open, close]
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
livetext-0.9.24 lib/html.rb
livetext-0.9.23 lib/html.rb