Sha256: 5dc321461bb8205cb9ba886b374dbabd1b76473b88a47e2165073d5a4d1a6b88
Contents?: true
Size: 1.16 KB
Versions: 2
Compression:
Stored size: 1.16 KB
Contents
module Weskit::WML::Formatters class Attribute < ItemFormatter def format attribute, indent = 0 content = "#{name attribute}#@assignment#{value attribute}" @formatter.indent content, indent end private def defaults { :assignment => '=', :code_start => '<<', :code_end => '>>', :quote => '"', :underscore => '_' } end def escape value value.gsub @quote, escape_sequence end def escape_sequence @quote * 2 end def text attribute "#{attribute.value}" end def name attribute "#{attribute.name}" end def code_value attribute "#@code_start#{text attribute}#@code_end" end def raw_value attribute text attribute end def text_value attribute string = escape text attribute string = "#@quote#{string}#@quote" string = "#@underscore#{string}" if attribute.translatable? end def value attribute method = if attribute.code? :code_value elsif attribute.text? :text_value else :raw_value end send method, attribute end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
weskit-0.2.0 | lib/weskit/wml/formatters/attribute.rb |
weskit-0.1.0 | lib/weskit/wml/formatters/attribute.rb |