Sha256: 3ad1b2b525ff6fbcd03282d806665d153781ea0938a058cc3b7ac95d5ba7f44c
Contents?: true
Size: 797 Bytes
Versions: 2
Compression:
Stored size: 797 Bytes
Contents
module It # A generic class for html tags. class Tag include ActionView::Helpers::TagHelper attr_reader :tag_name, :options # See It.tag for details. You can do everything there and save 6 characters. def initialize(tag_name, options = {}) raise TypeError, 'tag_name must be a String or Symbol' unless [String, Symbol].include?(tag_name.class) raise TypeError, 'options must be a Hash' unless options.is_a?(Hash) @tag_name = tag_name.to_sym @options = options.symbolize_keys end # Will be called from inside the helper to return the tag with the given content. def process(content = nil) # :nodoc: if content content_tag(@tag_name, content, @options) else tag(@tag_name, @options) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
it-2.0.0 | lib/it/tag.rb |
it-1.0.0 | lib/it/tag.rb |