Skip to content

Instantly share code, notes, and snippets.

@jina
Last active August 28, 2015 04:06
Show Gist options
  • Save jina/02bf4458b37e0125a182 to your computer and use it in GitHub Desktop.
Save jina/02bf4458b37e0125a182 to your computer and use it in GitHub Desktop.
# data/prefix.yml
css: "slds-"
# helpers/ds_helpers.rb
module DsHelpers
def pf(*classes)
classes.map! { |x| "#{data.prefix.css}#{x}" }.join(' ')
end
end
# in html wherever
<p class="<%= pf 'foo', 'goo', 'boo' %>">
Some content text
</p>
<hr class="<%= pf 'bar', 'har', 'yar' %>" />
# output in view source
<p class="slds-foo slds-goo slds-boo">
Some content text
</p>
<hr class="slds-bar slds-har slds-yar" />
@jina
Copy link
Author

jina commented Aug 28, 2015

Big thanks to @brixen & @swrainey for the pointers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment