Skip to content

Variables don't work in template strings #97

Closed

Description

@bcomnes

When you use a template in your tagged template string css, the browserify transform breaks.

var aColor = '#fff'

var css = sf`.some-class {
  background-color: ${aColor};
}`
CssSyntaxError: /Users/bret/repos/hyperamp/renderer/index.js:3:2: Unknown word while parsing file: /Users/bret/repos/hyperamp/renderer/index.js

  1 | .some-class {
  2 |   background-color: ,;
> 3 | }[object Object]
    |  ^

I started down the road of correcting the in-node implementation, but we are going to have to statically analyze the template string during the transform somehow. I'm not too familiar with this kind of thing. Any ideas?

bcomnes@112d7b7

This is related to #54 but specific to the way template variables are busted right now vs how :host gets used.

Activity

  1. ahdinosaur commented on Oct 2, 2016

    @ahdinosaur
    Member

    i wrote my thoughts on sheetify static evaluation in #54 (comment). meanwhile support for template strings has been merged into static-eval: browserify/static-eval#13. 🍍

  2. yoshuawuyts commented on Nov 16, 2016

    @yoshuawuyts
    Contributor

    Should be fixed in 6.0.1 which has the latest static-eval - holler if something's not working as expected

  3. ahdinosaur commented on Nov 17, 2016

    @ahdinosaur
    Member

    @yoshuawuyts you sure this works? you'd have to gather up and pass in all currently defined variables to static-eval, i thought you said you'd rather avoid the complexity.

  4. yoshuawuyts commented on Nov 18, 2016

    @yoshuawuyts
    Contributor

    Oh, didn't realize that's how it worked - nah this doesn't work then

    On Fri, Nov 18, 2016 at 12:53 AM Mikey notifications@github.com wrote:

    @yoshuawuyts https://github.com/yoshuawuyts you sure this works? you'd
    have to gather up and pass in all currently defined variables to
    static-eval, i thought you said you'd rather avoid the complexity.

    —
    You are receiving this because you were mentioned.

    Reply to this email directly, view it on GitHub
    #97 (comment),
    or mute the thread
    https://github.com/notifications/unsubscribe-auth/ACWleqIdJVsTOyJF4yn_qySkJbyCo5Byks5q_OjzgaJpZM4KMHN-
    .

  5. sepiropht commented on Sep 25, 2017

    @sepiropht

    i'm using the last version, and it still not fixed

  6. yoshuawuyts commented on Sep 25, 2017

    @yoshuawuyts
    Contributor
  7. sepiropht commented on Sep 25, 2017

    @sepiropht

    Thanks for the response ,but i don't sure if this solution work for my use case:
    I want to update position of an element with the last coords of mouse pointer.
    I don't know values of my css property in advance.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions