ShareWith
This is a Ruby gem thought to render the sharing links for the most popular networks.
ShareWith also introduces a syntax, built upon a YAML file, to declare parameters and templates, and elements to self-describe the service itself.
This YAML file will be used to generate the object that renders the templates in plain HTML text.
Installation
Install the gem and add to the application's Gemfile by executing:
$ bundle add share_with
If bundler is not being used to manage dependencies, install the gem by executing:
$ gem install share_with
Usage
As first step must require the gem:
require "share_with"
Then we can instantiate the Collection class and the list of services to load:
@collection = ShareWith::Collection.new(services: ["twitter", "facebook"])
Once filled the params required to render the template:
@collection.set_value_to_all("url", "https://freeaptitude.altervista.org/projects/share-with.html")
Finally we get the HTML code as a text string:
@collection.render_all("icon")
More Help
More info is available at: