Sha256: 9b676237e356fa1f50fa7f87ca123cdcc88a82ee219421fad619770d1464fafd

Contents?: true

Size: 798 Bytes

Versions: 10

Compression:

Stored size: 798 Bytes

Contents

# frozen_string_literal: true

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 = ''
          html += template('div', classes: "s-#{top_class.gsub(/m[ty]{1}-/, '')}", contents: nil) if top_class
          html += node.to_html
          html += template('div', classes: "s-#{bottom_class.gsub(/m[by]{1}-/, '')}", contents: nil) if bottom_class
          node.replace(html)
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
bootstrap-email-1.5.1 lib/bootstrap-email/converters/margin.rb
bootstrap-email-1.5.0 lib/bootstrap-email/converters/margin.rb
bootstrap-email-1.4.1 lib/bootstrap-email/converters/margin.rb
bootstrap-email-1.4.0 lib/bootstrap-email/converters/margin.rb
bootstrap-email-1.3.1 lib/bootstrap-email/converters/margin.rb
bootstrap-email-1.3.0 lib/bootstrap-email/converters/margin.rb
bootstrap-email-1.2.0 lib/bootstrap-email/converters/margin.rb
bootstrap-email-1.1.7 lib/bootstrap-email/converters/margin.rb
bootstrap-email-1.1.6 lib/bootstrap-email/converters/margin.rb
bootstrap-email-1.1.5 lib/bootstrap-email/converters/margin.rb