Class: Sal::Compiler Private

Inherits:
Temple::Filter
  • Object
show all
Defined in:
lib/sal/compiler.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Compiles HTML into Temple::HTML expressions

Instance Method Summary collapse

Instance Method Details

#call(exp) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



5
6
7
8
9
# File 'lib/sal/compiler.rb', line 5

def call(exp)
  [:multi,
   [:code, "_saldict = Sal::Wrapper.new(self)"],
   super]
end

#on_sal_code(code, tag, attrs, content) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/sal/compiler.rb', line 23

def on_sal_code(code, tag, attrs, content)
  tmp1, tmp2 = unique_name, unique_name
  content = compile(content)
  if code == 'yield'
    [:dynamic, code]
  else
    [:if, "(#{tmp1} = _saldict['#{code}'])",
     [:multi,
      [:code, "#{tmp2}  = _saldict"],
      [:code, "_saldict = #{tmp1}"],
      [:case, tmp1,
       ['Array',
        [:block, "#{tmp1}.each do |_saldict|",
         [:html, :tag, tag, ada(attrs), content]]],
       [:else,
        [:html, :tag, tag, ada(attrs), content]]],
      [:code, "_saldict = #{tmp2}"]]]
  end
end

#on_sal_tag(tag, attrs, content) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



11
12
13
# File 'lib/sal/compiler.rb', line 11

def on_sal_tag(tag, attrs, content)
  [:html, :tag, tag, format_attrs(attrs), compile(content)]
end

#on_sal_text(incode, text) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



15
16
17
18
19
20
21
# File 'lib/sal/compiler.rb', line 15

def on_sal_text(incode, text)
  if incode
    [:dynamic, "Sal::U.parse_for_html(_saldict, '#{text}')"]
  else
    [:static, text]
  end
end