Module: StaticMatic::Helpers::TagHelper
- Extended by:
- TagHelper
- Included in:
- StaticMatic::Helpers, TagHelper
- Defined in:
- lib/staticmatic/helpers/tag_helper.rb
Instance Method Summary collapse
-
#tag(name, options = {}, &block) ⇒ Object
Generates HTML tags:.
Instance Method Details
#tag(name, options = {}, &block) ⇒ Object
Generates HTML tags:
tag(:br) -> <br/> tag(:a, :href => ‘test.html’) { “Test” } -> <a href=“test.html”>Test</a>
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/staticmatic/helpers/tag_helper.rb', line 11 def tag(name, = {}, &block) [:id] ||= [:name] if [:name] output = "<#{name}" .keys.sort { |a, b| a.to_s <=> b.to_s }.each do |key| output << " #{key}=\"#{[key]}\"" if [key] end if block_given? output << ">" output << yield output << "</#{name}>" else format = @staticmatic.configuration.['haml'][:format] if format.nil? || format == :xhtml output << "/>" else output << ">" end end output end |