Skip to content

Unable to use brackets in string template #636

@C0DK

Description

@C0DK

I wanted to do a generic log-error on htmx errors, and include a timestamp to make it easier to find in logs. However until #123 is fixed, I need to use the basic js date function. To get an Iso Timestamp it seemed easy to do something like this: (new Date()).toISOString() giving me the following code:

<body 
 _="on htmx:responseError or htmx:sendError or htmx:sseError log detail then alert(`An unhandled exception occured - please screenshot me: \n${(new Date()).toISOString()}\n${detail.error}`)"
>

However the (great) hyperscript parser seems to dislike the ( inside a curly:

hyperscript errors were found on the following element: 
<body _="on htmx:responseError or…()}\\n${detail.error}`)"> 

 Expected ')' but found 'Date'

${(new Date()).toISOString()}

Is this a known bug or should i do something completely different?

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