Sha256: d80e0ff5f8452a241937aac50f3f30d29d5303e9f0c96a2c25be262c194f60a3
Contents?: true
Size: 1.28 KB
Versions: 1
Compression:
Stored size: 1.28 KB
Contents
# encoding: utf-8 # Option default_attributes # # A hash of default attributes for tags (`{tag => {attribute => default_value}}`). # Attributes of each tag will reverse merged with his default attributes, so you # don't have to write over and over that script tag has attribute `type` with value # `text/javascript`. For example, `%script` compiles to `<script type="text/javascript"></script>`. # Defaults to `{:script => {:type => "text/javascript"}, :form => {:method => "POST"}}` module Haml class Engine alias_method :__initialize__, :initialize def initialize(template, options = Hash.new) __initialize__(template, options) @options[:default_attributes] = Hash.new # symbolize keys @options[:default_attributes] = @options[:default_attributes].inject(Hash.new) do |options, pair| options.merge(pair.first.to_sym => pair.last) end end end module Precompiler alias_method :__prerender_tag__, :prerender_tag def prerender_tag(name, self_close, attributes) # merge given attributes with default attributes from options if default_attributes = @options[:default_attributes][name.to_sym] attributes = default_attributes.merge(attributes) end __prerender_tag__(name, self_close, attributes) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rango-0.1.1.1 | lib/rango/templates/exts/haml.rb |