Module: EvilFront

Defined in:
lib/evil-front.rb,
lib/evil-front/slim.rb,
lib/evil-front/english.rb,
lib/evil-front/helpers.rb,
lib/evil-front/russian.rb,
lib/evil-front/version.rb,
lib/evil-front/typograph.rb

Defined Under Namespace

Modules: English, Helpers, Russian, Typograph Classes: Engine

Constant Summary collapse

HTML_ESCAPE =
{ '&' => '&amp;',  '>' => '&gt;', '<' => '&lt;' }
VERSION =
'0.5.1'

Class Method Summary collapse

Class Method Details

.escape(string) ⇒ Object

Escape unsafe strings



14
15
16
17
18
19
20
21
# File 'lib/evil-front/helpers.rb', line 14

def self.escape(string)
  string = string.to_s
  if not string.respond_to?(:html_safe?) or string.html_safe?
    string
  else
    string.gsub(/[&><]/, HTML_ESCAPE).html_safe
  end
end

.html_safe(string) ⇒ Object

Call ‘html_safe` if String has this methods.



5
6
7
8
9
10
11
# File 'lib/evil-front/helpers.rb', line 5

def self.html_safe(string)
  if string.respond_to?(:html_safe)
    string.html_safe
  else
    string.to_s
  end
end

.install(sprockets) ⇒ Object

Install Evil Front to standalone Sprockets environment.



20
21
22
23
24
25
26
27
# File 'lib/evil-front.rb', line 20

def self.install(sprockets)
  RailsSassImages.install(sprockets)

  root = Pathname(__FILE__).dirname.join('..')
  sprockets.append_path(root.join('lib/assets/javascripts'))
  sprockets.append_path(root.join('lib/assets/stylesheets'))
  sprockets.append_path(root.join('vendor/assets/fonts'))
end

.set_slim_options!Object

Set default options to Slim



3
4
5
# File 'lib/evil-front/slim.rb', line 3

def self.set_slim_options!
  Slim::Engine.set_options(pretty: true, format: :html)
end