Class: Remarkably::Engines::HTML
- Inherits:
-
XML
- Object
- Base::Engine
- XML
- Remarkably::Engines::HTML
- Defined in:
- lib/remarkably/engines/html.rb,
lib/remarkably/engines/html/helpers.rb
Instance Attribute Summary
Attributes inherited from Base::Engine
Instance Method Summary collapse
- #bookmarklet(args, hash, &block) ⇒ Object
-
#initialize ⇒ HTML
constructor
A new instance of HTML.
- #style(args, hash, &block) ⇒ Object
Methods inherited from XML
Methods inherited from Base::Engine
#clear!, #method!, #method_missing, #missing_method, #to_s
Constructor Details
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 |