Skip to content

Instantly share code, notes, and snippets.

@aderaaij
Last active November 12, 2017 15:13
Show Gist options
  • Save aderaaij/a161dd205dfc8dfa0e111cc41afdeb47 to your computer and use it in GitHub Desktop.
Save aderaaij/a161dd205dfc8dfa0e111cc41afdeb47 to your computer and use it in GitHub Desktop.
In this template string we use a ternary conditional operator to only show the 'featured' part when it's available. If not available, the last part is omitted. From es6.io
const song = {
name: 'Dying to live',
artist: 'Tupac',
featuring: 'Biggie Smalls'
};
const markup = `
<div class="song">
<p>
${song.name} — ${song.artist}
${song.featuring ? `(Featuring ${song.featuring})` : ''}
</p>
</div>
`;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment