Class: Temple::Generators::RailsOutputBuffer

Inherits:
StringBuffer show all
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

#options

Instance Method Summary collapse

Methods inherited from StringBuffer

#on_dynamic, #return_buffer

Methods inherited from ArrayBuffer

#return_buffer

Methods inherited from Array

#return_buffer

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

included, #initialize

Methods included from Mixins::CompiledDispatcher

#compile

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_bufferObject



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 || #{options[:buffer_class]}.new"
  else
    "#{buffer} = #{options[:buffer_class]}.new"
  end
end