Sha256: 7c91268aa98aa4edbbf7a473fa2cbacf53a63818ca73ed266651eff9fc825293

Contents?: true

Size: 819 Bytes

Versions: 10

Compression:

Stored size: 819 Bytes

Contents

module BootstrapEmail
  module Converter
    class Margin < Base
      def build
        each_node("*[class^='my-'], *[class^='mt-'], *[class^='mb-'], *[class*=' my-'], *[class*=' mt-'], *[class*=' mb-']") do |node|
          top_class = node['class'][/m[ty]{1}-(lg-)?(\d+)/]
          bottom_class = node['class'][/m[by]{1}-(lg-)?(\d+)/]
          node['class'] = node['class'].gsub(/(m[tby]{1}-(lg-)?\d+)/, '').strip
          html = ''
          if top_class
            html += template('div', classes: "s-#{top_class.gsub(/m[ty]{1}-/, '')}", contents: nil)
          end
          html += node.to_html
          if bottom_class
            html += template('div', classes: "s-#{bottom_class.gsub(/m[by]{1}-/, '')}", contents: nil)
          end
          node.replace(html)
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
bootstrap-email-1.1.4 lib/bootstrap-email/converters/margin.rb
bootstrap-email-1.1.3 lib/bootstrap-email/converters/margin.rb
bootstrap-email-1.1.2 lib/bootstrap-email/converters/margin.rb
bootstrap-email-1.1.1 lib/bootstrap-email/converters/margin.rb
bootstrap-email-1.1.0 lib/bootstrap-email/converters/margin.rb
bootstrap-email-1.0.2 lib/bootstrap-email/converters/margin.rb
bootstrap-email-1.0.1 lib/bootstrap-email/converters/margin.rb
bootstrap-email-1.0.0 lib/bootstrap-email/converters/margin.rb
bootstrap-email-1.0.0.alpha4 lib/bootstrap-email/converters/margin.rb
bootstrap-email-1.0.0.alpha3.1 lib/bootstrap-email/converters/margin.rb