Skip to content

Support multi-line attributes #291

@alexbiehl

Description

@alexbiehl

It would be great if the the Hamlet parser could recognize and preserve multi-line string attribute values.

In my case, I’m trying to use Alpine.js’s x-data with a complex state, but am forced to cram everything onto one line or split into unreadable concatenations.

See their example at on their getting started guide:

<div
    x-data="{
        search: '',
 
        items: ['foo', 'bar', 'baz'],
 
        get filteredItems() {
            return this.items.filter(
                i => i.startsWith(this.search)
            )
        }
    }"
>
    <input x-model="search" placeholder="Search...">
 
    <ul>
        <template x-for="item in filteredItems" :key="item">
            <li x-text="item"></li>
        </template>
    </ul>
</div>

Currently the parser fails as it doesn't expect a EOL in an attribute value.

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