Skip to content

template strings for sheetify #31

Closed

Description

@yoshuawuyts

I'm quite fond of hyperx, and how they use template strings. Might be cool to support them too in sheetify, e.g.

const vdom = require('virtual-dom')
const hyperx = require('hyperx')
const sf = require('sheetify')
const hx = hyperx(vdom.h)

const prefix = sf`
  h1 {
    text-align: center;
  }
`

const tree = hx`
  <section className=${prefix}>
    <h1>My beautiful, centered title</h1>
  </section>
`

console.log(vdom.create(tree).toString())

Does this make sense? Am I mad? I feel like this might be a bit too much / we really need to start thinking of how to consolidate the API as currently there's already too many ways of doing things haha, though this might be very useful.

Activity

  1. ahdinosaur commented on Jan 10, 2016

    @ahdinosaur
    Member

    ooh, cool idea.

    we really need to start thinking of how to consolidate the API as currently there's already too many ways of doing things

    i agree. :)

  2. added this to the transform-only milestone on Jan 17, 2016
  3. yoshuawuyts commented on Jan 21, 2016

    @yoshuawuyts
    ContributorAuthor

    mdn reference on how to create tagged template strings:

    var a = 5;
    var b = 10;
    
    function tag(strings, ...values) {
      console.log(strings[0]); // "Hello "
      console.log(strings[1]); // " world "
      console.log(values[0]);  // 15
      console.log(values[1]);  // 50
    
      return "Bazinga!";
    }
    
    tag`Hello ${ a + b } world ${ a * b }`;
    // "Bazinga!"
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

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions