Module: It

Defined in:
lib/it.rb,
lib/it/tag.rb,
lib/it/link.rb,
lib/it/plain.rb,
lib/it/helper.rb,
lib/it/parser.rb,
lib/it/version.rb,
lib/it/interpolation.rb

Overview

Namespace of the gem.

Defined Under Namespace

Modules: Helper Classes: Interpolation, Link, Parser, Plain, Tag

Constant Summary collapse

VERSION =
'2.0.0'.freeze

Class Method Summary collapse

Class Method Details

.it(identifier, options = {}) ⇒ Object

It outside of your views. See documentation at Helper#it



16
17
18
19
20
21
# File 'lib/it.rb', line 16

def self.it(identifier, options = {})
  Parser.new(
    I18n.t(identifier, **Parser.backend_options(options).symbolize_keys),
    options.stringify_keys
  ).process
end

Creates a new link to be used in it.

  • href: The url for the link. You may specify it as a String or as a named route like article_path. It’s not possible to specify a Hash like {controller: "articles", action: "index"} directly. Use the url_for helper, if you would like to specify your links like that.

  • options: The options as an Hash. Use them like you would with link_to. (optional)



29
30
31
# File 'lib/it.rb', line 29

def self.link(href, options = {})
  It::Link.new(href, options)
end

.plain(template = '%s') ⇒ Object

Creates a new plain replacement to be used in it.

  • template: A string to be used as the template. An example would be "%s[http://www.rubyonrails.org]". Defaults to "%s". (optional)



37
38
39
# File 'lib/it.rb', line 37

def self.plain(template = '%s')
  It::Plain.new(template)
end

.tag(tag_name, options = {}) ⇒ Object

Creates a new tag to be used in it.

  • tag_name: The name of the tag as a Symbol or String.

  • options: The options will become attributes on the tag. (optional)



45
46
47
# File 'lib/it.rb', line 45

def self.tag(tag_name, options = {})
  It::Tag.new(tag_name, options)
end