Sha256: 8d544d891384fbb6c87015cfe5457865e461d74a2846bfcbc9390469cade0bca

Contents?: true

Size: 547 Bytes

Versions: 2

Compression:

Stored size: 547 Bytes

Contents

require 'template'

class Template
  class OutputBuffer
    alias << append

    # allow tags in haml to have dynamic attributes
    def attributes(class_id, obj_ref, *attributes_hashes)
      attributes = class_id

      attributes_hashes.each do |hash|
        attributes.update hash
      end

      result = attributes.collect do |attr, value|
        if value == true
          next " #{attr}"
        elsif value == false
          next
        else
          " #{attr}='#{value}'"
        end
      end

      result.join
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
opal-haml-0.4.0 opal/opal-haml.rb
opal-haml-0.3.0 opal/opal-haml.rb