Skip to content

Really simple OO Monkey Patch on String to add HTML convenience methods

License

Notifications You must be signed in to change notification settings

coyote/html_tagger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

HtmlTagger

Installation

Add this line to your application's Gemfile:

gem 'html_tagger'

And then execute:

$ bundle

Or install it yourself as:

$ gem install html_tagger

Usage

Wrapper methods that will wrap a string in a span tag with the appropriate attributes:

  • bold
  • italics
  • underline, underscore
  • strikeout
  • oblique
  • color(text_color)
  • subscript
  • superscript
  • add_class(class_to_set)
  • tag_id(id_to_set)

These methods are proxied to the method:

  • styles(*list_of_sytles) The list_of_styles is a list of strings, which are mentioned above. The will all go on the same span tag.

The #styles method can take an optional first argument of a symbol which will determine the block type:

  • styles(:block_type, *list_of_styles) -- :block_type can be :p, :div or :span. :span is the same as no first argument.

A link can be created with

  • link(linked_to_url), or an element in the
  • styles('link:linked_to_url', *other_style_elements)

Exceptions

  • When an attempt to add more than one ID element to the same tag
  • When a block type other than SPAN, DIV, or P is specified
  • When an unknown trait is specified to #styles

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Added some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

endorse

About

Really simple OO Monkey Patch on String to add HTML convenience methods

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages