3

In my Rails 4 application I have a number of SASS variables like this one:

$primary_color: #ec4158;

Is it possible to access that variable from a Rails class somehow?

Thanks for any help.

Tintin81
  • 9,821
  • 20
  • 85
  • 178
  • Not trivially. Why would you want to? Shouldn't those variables be going the other way, since you can make a Sass file ERb, but not vice-versa? – Dave Newton Feb 09 '14 at 15:38
  • @DaveNewton: I am using [Prawn](http://prawnpdf.org) to build a PDF and Prawn comes with its own mark up language. I would like to use my website's colour scheme in those PDFs without having to copy the values over manually. – Tintin81 Feb 09 '14 at 15:55
  • I guess you could use the Sass parser to load them all up somehow. – Dave Newton Feb 09 '14 at 16:12

1 Answers1

0

I think you have to make it the other way around.

  1. define constants in an initializer or somewhere else (like this)
  2. generate your sass using erb (yourstyle.sass.erb)
  3. use the same constants in your prawn generation
Community
  • 1
  • 1
phoet
  • 18,688
  • 4
  • 46
  • 74