class Tilt::HerbTemplate
Public Instance Methods
freeze_string_literals?()
click to toggle source
# File lib/tilt/herb.rb 106 def freeze_string_literals? 107 @freeze_string_literals 108 end
precompiled_template(locals)
click to toggle source
# File lib/tilt/herb.rb 102 def precompiled_template(locals) 103 @src 104 end
prepare()
click to toggle source
# File lib/tilt/herb.rb 66 def prepare 67 @options[:preamble] = false 68 @options[:postamble] = false 69 @options[:ensure] = true 70 71 # Unlike Erubi, Herb uses the filename when reporting errors, so pass 72 # the file Tilt loaded the template from if the caller did not set one. 73 @options[:filename] ||= file 74 75 engine_class = @options[:engine_class] || Herb::Engine 76 77 # If :freeze option is given, the intent is to setup frozen string 78 # literals in the template. So enable frozen string literals in the 79 # code Tilt generates if the :freeze option is given. 80 if @freeze_string_literals = !!@options[:freeze] 81 # Passing the :freeze option to Herb sets the 82 # frozen-string-literal magic comment, which doesn't have an effect 83 # with Tilt as Tilt wraps the resulting code. Worse, the magic 84 # comment appearing not at the top of the file can cause a warning. 85 # So remove the :freeze option before passing to Herb. 86 @options.delete(:freeze) 87 88 # Herb by default appends .freeze to template literals, but that is 89 # not necessary and slows down code when Tilt is using frozen string 90 # literals, so pass the :freeze_template_literals option to not 91 # append .freeze. 92 @options[:freeze_template_literals] = false 93 end 94 95 @engine = engine_class.new(@data, @options) 96 @outvar = @engine.bufvar 97 @src = @engine.src 98 99 @engine 100 end