Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiler preserves newlines in class objects, causing Unterminated String Constant errors #1306

Closed
klardotsh opened this issue Nov 2, 2015 · 4 comments
Assignees

Comments

@klardotsh
Copy link

Given a tag consisting of the following:

<so-input>
    <label if={ opts.label } for="theInput">{ opts.label }</label>
    <input id="theInput"
        class={
            'is-invalid': note.type === 1,
            'is-valid': ofMinLength && note.type !== 1
        }>

    <script>
        require('./so-input.js').call(this);
    </script>
</so-input>

Which validates through $(npm bin)/riot --check so-input.tag --type es6

The compiled output will consist of the following, which contains an Unterminated String Constant at the end of Line 1 (which will break our Webpack build)

riot.tag2('so-input', '<label if="{opts.label}" for="theInput">{opts.label}</label> <input id="theInput" class="{\'is-invalid\': note.type === 1,
            \'is-valid\': ofMinLength && note.type !== 1}">', '', '', function(opts) {
require('./so-input.js').call(this);
}, '{ }');

By moving the class definitions to a single line, the compiler will output valid JS:

<so-input>
    <label if={ opts.label } for="theInput">{ opts.label }</label>
    <input id="theInput"
        class={'is-invalid': note.type === 1, 'is-valid': ofMinLength && note.type !== 1}>

    <script>
        require('./so-input.js').call(this);
    </script>
</so-input>
riot.tag2('so-input', '<label if="{opts.label}" for="theInput">{opts.label}</label> <input id="theInput" class="{\'is-invalid\': note.type === 1, \'is-valid\': ofMinLength && note.type !== 1}">', '', '', function(opts) {
require('./so-input.js').call(this);
}, '{ }');

The newlines should either be stripped, or a closing quote and + operator (to concat with the string on the next line) should be inserted.

@GianlucaGuarini
Copy link
Member

@aMarCruz Is something you could check before releasing the 2.3.0 release?

@aMarCruz
Copy link
Contributor

aMarCruz commented Nov 2, 2015

I will check this

@klardotsh
Copy link
Author

Any updates in this regard? I know you guys have been busy with releases, but curious anyway :)

@aMarCruz
Copy link
Contributor

please test with riot-compiler v2.3.1, it is fixed

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

No branches or pull requests

3 participants