Last active
July 17, 2018 00:31
-
-
Save roblevintennis/e776c245adc052e6060250e76b3d800f to your computer and use it in GitHub Desktop.
String Interpolation Refactoring Examples
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% svgIconName = '' | |
case story.story_type | |
when 'deliverable' | |
svgIconName = 'icon-deliverable' | |
when 'milestone' | |
svgIconName = 'icon-milestone' | |
when 'task' | |
svgIconName = 'icon-task' | |
when 'issue' | |
svgIconName = 'icon-issue' | |
end | |
%> | |
<div> | |
Normal markup stuff... | |
<span class='story-icon'> | |
<%= svg_icon(svgIconName, 'icon-fill-'+story.story_type+' legacy-filled-icons-sqkd-18b901') %> | |
</span> | |
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
styles = require './story.scss' | |
templateHelpers: -> | |
iconClass: @_iconClassForStoryType | |
_iconClassForStoryType: (type) -> | |
fillKlass = styles['legacy-filled-icons'] | |
switch type | |
when 'task' | |
iconClassName = "#{fillKlass} icon-fill-highlight" | |
when 'deliverable' | |
iconClassName = "#{fillKlass} icon-fill-action" | |
when 'milestone' | |
iconClassName = "#{fillKlass} icon-fill-primary" | |
when 'issue' | |
iconClassName = "#{fillKlass} icon-fill-caution" | |
else | |
return '' | |
iconClassName |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%= @svgIcon("icon-#{@story_type}", @iconClass(@story_type)) %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.legacy-filled-icons { | |
composes: legacy-filled-icons-sqkd-18b901 from 'internal/base/utilities.scss'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment