Class: Faml::Compiler
- Inherits:
-
Temple::Parser
- Object
- Temple::Parser
- Faml::Compiler
show all
- Defined in:
- lib/faml/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
30
31
32
33
34
|
# File 'lib/faml/compiler.rb', line 30
def initialize(*)
super
@text_compiler = TextCompiler.new
@filename = options[:filename]
end
|
Class Method Details
.find_and_preserve(input) ⇒ Object
45
46
47
48
49
50
51
52
|
# File 'lib/faml/compiler.rb', line 45
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}>#{Helpers.preserve($3)}</#{$1}>"
end
end
|
Instance Method Details
#call(ast) ⇒ Object
36
37
38
39
40
41
42
43
|
# File 'lib/faml/compiler.rb', line 36
def call(ast)
compile(ast)
rescue Error => e
if @filename && e.lineno
e.backtrace.unshift "#{@filename}:#{e.lineno}"
end
raise e
end
|