Module: Tiny::ActionViewAdditions

Includes:
Buffering, Markup
Defined in:
lib/tiny.rb

Instance Method Summary collapse

Methods included from Markup

#cdata, #comment, #doctype, #html_tag

Methods included from Buffering

#append!, #raw

Instance Method Details

#append(markup) ⇒ Object

Appends sanitized text to the content.

See Also:



450
451
452
# File 'lib/tiny.rb', line 450

def append(markup)
  super(markup).html_safe
end

#block_from_template?(block) ⇒ Boolean

Returns true if the block was originated in an ERB or HAML template.

Returns:

  • (Boolean)


455
456
457
# File 'lib/tiny.rb', line 455

def block_from_template?(block)
  block && eval('defined?(output_buffer)', block.binding) == 'local-variable'
end

#with_buffer(*args) {|*args| ... } ⇒ String

Extracts a section of a template or buffers a block not originated from an template.

Parameters:

  • args (any)

    n number of arguments to be passed to block evaluation.

Yields:

  • (*args)

    HAML block or content block.

Returns:

See Also:



444
445
446
# File 'lib/tiny.rb', line 444

def with_buffer(*args, &block)
  block_from_template?(block) ? capture(*args, &block) : super
end