Class: Temple::Generators::RailsOutputBuffer
- Inherits:
-
StringBuffer
- Object
- Temple::Generator
- Array
- ArrayBuffer
- StringBuffer
- Temple::Generators::RailsOutputBuffer
- Defined in:
- lib/temple/generators/rails_output_buffer.rb
Overview
Implements a rails output buffer.
@output_buffer = ActiveSupport::SafeBuffer
@output_buffer.safe_concat "static"
@output_buffer.safe_concat dynamic.to_s
@output_buffer
Constant Summary
Constants included from Utils
Utils::ESCAPE_HTML, Utils::ESCAPE_HTML_PATTERN
Instance Attribute Summary
Attributes included from Mixins::Options
Instance Method Summary collapse
Methods inherited from StringBuffer
Methods inherited from ArrayBuffer
Methods inherited from Array
Methods inherited from Temple::Generator
#on, #on_capture, #on_code, #on_dynamic, #on_multi, #on_newline, #on_static, #postamble, #preamble, #restore_buffer, #return_buffer, #save_buffer
Methods included from Mixins::Options
Methods included from Mixins::CompiledDispatcher
Methods included from Utils
#empty_exp?, #escape_html, #escape_html_safe, #indent_dynamic, #unique_name
Instance Method Details
#call(exp) ⇒ Object
18 19 20 |
# File 'lib/temple/generators/rails_output_buffer.rb', line 18 def call(exp) [preamble, compile(exp), postamble].flatten.compact.join('; '.freeze) end |
#concat(str) ⇒ Object
30 31 32 |
# File 'lib/temple/generators/rails_output_buffer.rb', line 30 def concat(str) "#{buffer}.safe_concat((#{str}))" end |
#create_buffer ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/temple/generators/rails_output_buffer.rb', line 22 def create_buffer if buffer == '@output_buffer' "#{buffer} = output_buffer || #{[:buffer_class]}.new" else "#{buffer} = #{[:buffer_class]}.new" end end |