shama / yo-yoify

Transform choo, yo-yo or bel template strings into pure and fast document calls
111 stars 17 forks source link

support for properties like `disabled` or `selected` without "=" notation #7

Closed SilentCicero closed 8 years ago

SilentCicero commented 8 years ago

Everytime I try to yo-yoify yo templates with properties like disabled or selected I get the error:

SyntaxError: Unterminated string constant (51:18)

example:

var yo = require("yo-yo")

function button () { 
    var disabled = "disabled"
     return yo`<button ${disabled}>Some Button</button>`
}

in order to make the above work I have to do something like this:

var yo = require("yo-yo")

function button () { 
    var disabled = "1"
     return yo`<button disabled=${disabled}>Some Button</button>`
}

@shama thoughts?

shama commented 8 years ago

I just hit this bug today. Currently it checks for boolean attributes by seeing if they're set to 'true' or 'false'. But if it's set to an expression, it can't tell.

Instead, it should detect if it's an expression and dynamically determine the boolean.

shama commented 8 years ago

Fixed on 3.2.2 Thanks!

derhuerst commented 8 years ago

I think I have this issue, with yo-yoify@3.4.1:

const row = (finishTodo, unfinishTodo, removeTodo) => (todo, index) => {
    const toggle = todo.finished
        ? () => unfinishTodo(index)
        : () => finishTodo(index)
    const remove = () => removeTodo(index)
    return yo `
        <li>
            <input type="checkbox"
                ${todo.finished ? 'checked' : ''}/>
        </li>`
}
Unterminated string constant (19:18)
shama commented 8 years ago

@derhuerst It might be because the lack of space on }/> vs } />. I know there is a bug in the html parser that requires that for <br/> vs <br />.

derhuerst commented 8 years ago

@shama

I know there is a bug in the html parser that requires that for <br/> vs <br />.

Where can I report that issue?

shama commented 8 years ago

@derhuerst hyperx is the parser under the hood.