Class Haml::Buffer
In: lib/haml/buffer.rb
lib/haml/template/plugin.rb
Parent: Object

This class is used only internally. It holds the buffer of HTML that is eventually output as the resulting document. It‘s called from within the precompiled code, and helps reduce the amount of processing done within `instance_eval`ed code.

Methods

Included Modules

Haml::Helpers Haml::Util

Attributes

active  [W]  @return [Boolean] @see active?
buffer  [RW]  The string that holds the compiled HTML. This is aliased as `_erbout` for compatibility with ERB-specific code.

@return [String]

capture_position  [RW]  nil if there‘s no capture_haml block running, and the position at which it‘s beginning the capture if there is one.

@return [Fixnum, nil]

options  [RW]  The options hash passed in from {Haml::Engine}.

@return [{String => Object}] @see Haml::Engine#options_for_buffer

upper  [RW]  The {Buffer} for the enclosing Haml document. This is set for partials and similar sorts of nested templates. It‘s `nil` at the top level (see \{toplevel?}).

@return [Buffer]

Public Class methods

Merges two attribute hashes. This is the same as `to.merge!(from)`, except that it merges id, class, and data attributes.

ids are concatenated with `"_"`, and classes are concatenated with `" "`. data hashes are simply merged.

Destructively modifies both `to` and `from`.

@param to [{String => String}] The attribute hash to merge into @param from [{String => to_s}] The attribute hash to merge from @return [{String => String}] `to`, after being merged

@param upper [Buffer] The parent buffer @param options [{Symbol => Object}] An options hash.

  See {Haml::Engine#options\_for\_buffer}

Public Instance methods

Whether or not this buffer is currently being used to render a Haml template. Returns `false` if a subtemplate is being rendered, even if it‘s a subtemplate of this buffer‘s template.

@return [Boolean]

Modifies the indentation of the document.

@param tab_change [Fixnum] The number of tabs by which to increase

  or decrease the document's indentation

@return [Boolean] Whether or not the format is HTML4

@return [Boolean] Whether or not the format is HTML5.

@return [Boolean] Whether or not the format is any flavor of HTML

Takes the various information about the opening tag for an element, formats it, and appends it to the buffer.

Appends text to the buffer, properly tabulated. Also modifies the document‘s indentation.

@param text [String] The text to append @param tab_change [Fixnum] The number of tabs by which to increase

  or decrease the document's indentation

@param dont_tab_up [Boolean] If true, don‘t indent the first line of `text`

Remove the whitespace from the right side of the buffer string. Doesn‘t do anything if we‘re at the beginning of a capture_haml block.

@return [Fixnum] The current indentation level of the document

Sets the current tabulation of the document.

@param val [Fixnum] The new tabulation

@return [Boolean] Whether or not this buffer is a top-level template,

  as opposed to a nested partial

@return [Boolean] Whether or not the format is XHTML

[Validate]