26

Is there a way to use variables from my Ruby application inside a Sass file?

cimmanon
  • 67,211
  • 17
  • 165
  • 171
alik
  • 3,820
  • 9
  • 41
  • 55

1 Answers1

33

You can add .erb extention to your .sass file and then add your variables just like in regular .erb file:

<%= APP_CONFIG[:yourkey] %>

More information:

htanata
  • 36,666
  • 8
  • 50
  • 57
Laurynas
  • 3,829
  • 2
  • 32
  • 22
  • 10
    Be aware when doing this that Sass files are by default only compiled once and then served statically. – montrealmike May 12 '15 at 17:29
  • Yes...so it doesn't make sense to have a dynamic object accessible in a SASS/CSS file like you would in an html template. – Hari Honor Jan 30 '20 at 10:43