Sha256: a7565117e73fe53997bec283364ab8c1239156ef23638316de9fa218aa95298a

Contents?: true

Size: 631 Bytes

Versions: 3

Compression:

Stored size: 631 Bytes

Contents

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)
    api.out open
    yield
    api.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

3 entries across 3 versions & 1 rubygems

Version Path
livetext-0.9.27 lib/livetext/html.rb
livetext-0.9.26 lib/livetext/html.rb
livetext-0.9.25 lib/livetext/html.rb