Class: FastHaml::Compiler
- Inherits:
-
Temple::Parser
- Object
- Temple::Parser
- FastHaml::Compiler
show all
- Defined in:
- lib/fast_haml/compiler.rb
Defined Under Namespace
Classes: UnparsableRubyCode
Constant Summary
collapse
- DEFAULT_AUTO_CLOSE_TAGS =
%w[
area base basefont br col command embed frame hr img input isindex keygen
link menuitem meta param source track wbr
]
- DEFAULT_PRESERVE_TAGS =
%w[pre textarea code]
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Compiler.
25
26
27
28
|
# File 'lib/fast_haml/compiler.rb', line 25
def initialize(*)
super
@text_compiler = TextCompiler.new
end
|
Class Method Details
.find_and_preserve(input) ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'lib/fast_haml/compiler.rb', line 34
def self.find_and_preserve(input)
re = /<(#{options[:preserve].map(&Regexp.method(:escape)).join('|')})([^>]*)>(.*?)(<\/\1>)/im
input.to_s.gsub(re) do |s|
s =~ re "<#{$1}#{$2}>#{preserve($3)}</#{$1}>"
end
end
|
.preserve(input) ⇒ Object
43
44
45
46
|
# File 'lib/fast_haml/compiler.rb', line 43
def self.preserve(input)
input.to_s.chomp("\n").gsub(/\n/, '
').gsub(/\r/, '')
end
|
Instance Method Details
#call(ast) ⇒ Object
30
31
32
|
# File 'lib/fast_haml/compiler.rb', line 30
def call(ast)
compile(ast)
end
|