Skip to content

Grammar: Tagged template literals: fn(a)""" should be allowable syntax #4467

Closed
@monstersintokyo

Description

@monstersintokyo

Thanks to the addition of tagged template literals it is possible to natively use styled components in CoffeeScript 1.12.

Hence something like

const Button = styled.button`
  background: white;
  color: palevioletred;
  font-size: 1em;
  margin: 1em;
  padding: 0.25em 1em;
  border: 2px solid palevioletred;
  border-radius: 3px;
`;

translates to

Button = styled.button"""
  background: white
  color: palevioletred
  font-size: 1em
  margin: 1em
  padding: 0.25em 1em
  border: 2px solid palevioletred
  border-radius: 3px
"""

in CoffeeScript.

Styled components enable us to to override attributes in given components like so:

const TomatoButton = styled(Button)`
  color: tomato;
  border-color: tomato;
`;

When trying to translate this to CoffeeScript

TomatoButton = styled(Button)"""
  color: tomato
  border-color: tomato
"""

the compiler is throwing:

error: unexpected string
TomatoButton = styled(Button)"""
                             ^^^

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions