Sha256: 0fc4ebf4280834ca71f5e9dbb02b0627ccb5ff4b0866c27138022bed0317e947
Contents?: true
Size: 959 Bytes
Versions: 2
Compression:
Stored size: 959 Bytes
Contents
module StaticMatic module Helpers module TagHelper self.extend self # Generates HTML tags: # # tag(:br) -> <br/> # tag(:a, :href => 'test.html') { "Test" } -> <a href="test.html">Test</a> # def tag(name, options = {}, &block) options[:id] ||= options[:name] if options[:name] output = "<#{name}" options.keys.sort { |a, b| a.to_s <=> b.to_s }.each do |key| output << " #{key}=\"#{options[key]}\"" if options[key] end if block_given? output << ">" output << yield output << "</#{name}>" else format = @staticmatic.configuration.engine_options['haml'][:format] if format.nil? || format == :xhtml output << "/>" else output << ">" end end output end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
staticmatic3-2.1.10 | lib/staticmatic/helpers/tag_helper.rb |
staticmatic3-2.1.9 | lib/staticmatic/helpers/tag_helper.rb |