diff --git a/README.md b/README.md index bcb899b..8941b02 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,29 @@ welcome.html.haml => welcome.html.inky-haml pw_reset.html.erb => pw_reset.html.inky-erb ``` +## Other options + +### Column Count + +You can change the column count in the initializer too: + +```ruby +# config/initializers/inky.rb +Inky.configure do |config| + config.column_count = 24 +end +``` + +Make sure to change the SASS variable as well: + +```sass +# assets/stylesheets/foundation_emails.scss +# ... +$grid-column-count: 24; + +@import "foundation-emails"; +``` + ## Custom Elements Inky simplifies the process of creating HTML emails by expanding out simple tags like `` and `` into full table syntax. The names of the tags can be changed with the `components` setting. diff --git a/lib/inky.rb b/lib/inky.rb index e79881c..e0c1864 100644 --- a/lib/inky.rb +++ b/lib/inky.rb @@ -25,7 +25,7 @@ def initialize(options = {}) self.component_lookup = components.invert - self.column_count = options[:column_count] || 12 + self.column_count = options[:column_count] || ::Inky.configuration.column_count self.component_tags = components.values end diff --git a/lib/inky/configuration.rb b/lib/inky/configuration.rb index 3423ca7..90026e3 100644 --- a/lib/inky/configuration.rb +++ b/lib/inky/configuration.rb @@ -15,6 +15,7 @@ def self.configuration=(config) # ``` # Inky.configure do |config| # config.template_engine = :slim + # config.column_count = 24 # end # ``` def self.configure @@ -22,10 +23,11 @@ def self.configure end class Configuration - attr_accessor :template_engine + attr_accessor :template_engine, :column_count def initialize @template_engine = :erb + @column_count = 12 end end end diff --git a/lib/inky/rails/template_handler.rb b/lib/inky/rails/template_handler.rb index 5389dfa..689b725 100644 --- a/lib/inky/rails/template_handler.rb +++ b/lib/inky/rails/template_handler.rb @@ -14,6 +14,7 @@ def engine_handler def call(template) compiled_source = engine_handler.call(template) + "Inky::Core.new.release_the_kraken(begin; #{compiled_source};end)" end diff --git a/spec/configuration_spec.rb b/spec/configuration_spec.rb index 862abc2..d2e6615 100644 --- a/spec/configuration_spec.rb +++ b/spec/configuration_spec.rb @@ -14,11 +14,17 @@ end describe "#configuration=" do - it "can set value" do + it "can set template_engine" do config = Inky::Configuration.new config.template_engine = :haml expect(config.template_engine).to eq(:haml) end + + it "can set column_count" do + config = Inky::Configuration.new + config.column_count = 4 + expect(config.column_count).to eq(4) + end end describe "#configuration=" do diff --git a/spec/grid_spec.rb b/spec/grid_spec.rb index b0e0be1..a793859 100644 --- a/spec/grid_spec.rb +++ b/spec/grid_spec.rb @@ -57,6 +57,50 @@ compare(input, expected) end + it 'creates a single column with default large and small classes' do + input = 'One' + expected = <<-HTML + + + + + + +
One
+ + HTML + + compare(input, expected) + end + + it 'creates a single column with default large and small classes using the column_count option' do + begin + @previous_column_count = Inky.configuration.column_count + + Inky.configure do |config| + config.column_count = 5 + end + + input = 'One' + expected = <<-HTML + + + + + + +
One
+ + HTML + + compare(input, expected) + ensure + Inky.configure do |config| + config.column_count = @previous_column_count + end + end + end + it 'creates a single column with first and last classes' do input = 'One' expected = <<-HTML