Skip to content
This repository has been archived by the owner on Nov 21, 2021. It is now read-only.

Allow all premailer options #34

Open
gdogaru opened this issue Jun 26, 2015 · 2 comments
Open

Allow all premailer options #34

gdogaru opened this issue Jun 26, 2015 · 2 comments
Assignees

Comments

@gdogaru
Copy link

gdogaru commented Jun 26, 2015

Premailer has some other options, some only for Nokogiri, but since hprikot is no longer maintained that looks like the way to go.
Can you remove the option check and pass all options directly to premailer, or only the options that are not grunt-premailer specific?
this way you don't have to update the project every premailer adds a new option

@dwightjack
Copy link
Owner

Hi,

ATM the task just parses passed in options to arguments which are then passed to a ruby script.
Inside the ruby script I'm using OptionParser to convert them back to a ruby hash.

For what i can understand (not a ruby dev) OptionParser needs options to be specified in it's configuration, so I don't know if it's possibile to pass in unknown options.

Any hint on this?
Thanks!

@robert-stewart
Copy link

Hi @dwightjack ,
Love having grunt-premailer but am really missing the escapeUrlAttributes option. Did some quick searching around and apparently you can pass unknown options with OptionParser. I know very little about Ruby but hopefully this helps. Thread: https://www.ruby-forum.com/topic/88081
And the code is:

unknown=[] #this is the array where the unknown options will be put

begin
  option_parser.parse! argv
rescue OptionParser::InvalidOption => e
  e.recover argv
  #recover just put the unknown option back into argv, so I extract it
again and put it into unknown
  unknown << argv.shift

  #if argv still contains some elements, and the first one doesn't start
with a -, i.e is the argument for the unknown option, I remove it as
well
  unknown << argv.shift if argv.size>0 and temp.first[0..0]!='-'
  # go on with parsing
  retry
end

puts unknown

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants