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:



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

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)


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

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:



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

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