Class: Remarkably::Engines::HTML

Inherits:
XML show all
Defined in:
lib/remarkably/engines/html.rb,
lib/remarkably/engines/html/helpers.rb

Instance Attribute Summary

Attributes inherited from Base::Engine

#remarkably_engine

Instance Method Summary collapse

Methods inherited from XML

#method!, #text

Methods inherited from Base::Engine

#clear!, #method!, #method_missing, #missing_method, #to_s

Constructor Details

#initializeHTML

Returns a new instance of HTML.



8
9
10
11
# File 'lib/remarkably/engines/html.rb', line 8

def initialize
  super
  @css_engine = Engines::CSS.new
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Remarkably::Base::Engine

Instance Method Details

#bookmarklet(args, hash, &block) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/remarkably/engines/html/helpers.rb', line 4

def bookmarklet args, hash, &block
  inline_javascript = args.shift.split("\n").map{|l|l.strip}.join('')
  inline_javascript.gsub!( '%', '%25' )
  { "'" => "%27",
    '"' => "%22",
    '&' => "%26",
    '/' => "%2F",
  }.each_pair do |key,value|
    inline_javascript.gsub!( key, value )
  end
  hash[:href]=%|javascript:(function(){#{inline_javascript}})();|
  method!( :a, args, hash, &block )
end

#style(args, hash, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/remarkably/engines/html.rb', line 12

def style args, hash, &block
  if block_given?
    @css_engine.clear!
    @context.remarkably_engine = @css_engine
    block.call
    @context.remarkably_engine = self
    args = ["\n#{@css_engine}"]+args
  end
  method!( :style, args, hash )
end