Class: Matte::FromHTML
- Inherits:
-
Object
- Object
- Matte::FromHTML
- Defined in:
- lib/matte.rb
Overview
convert [:html] s-expressions into [:matte] s-expressions
Instance Method Summary collapse
- #call(document) ⇒ Object
-
#initialize(options = {}) ⇒ FromHTML
constructor
A new instance of FromHTML.
Constructor Details
#initialize(options = {}) ⇒ FromHTML
Returns a new instance of FromHTML.
120 121 122 |
# File 'lib/matte.rb', line 120 def initialize = {} @conf = end |
Instance Method Details
#call(document) ⇒ Object
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 |
# File 'lib/matte.rb', line 124 def call document # document = Marshal.load Marshal.dump document # not the best solution, but at least it works! Matte.find_all_sexps(document, [:html, :tag]).each do |tag| next unless tag[2].start_with? 'matte:' tag_name = tag[2].split(':').last.downcase case tag_name when "ph" # get placeholder name id = Matte.get_attr_for_html(tag, "id") raise Temple::InvalidExpression.new "placeholder must have a constant name" unless id.is_a? String tag.clear tag.push :matte, :placeholder, id when "mixin" id = Matte.get_attr_for_html(tag, "id") body = tag[4] raise Temple::InvalidExpression.new "mixin must have a constant name" unless id.is_a? String tag.clear tag.push :matte, :mixin, id, body end end pp document document end |