Search code examples
hyperscript

Go to a url based on an expression


<input class="new-item" name="description" value="" placeholder="e.g. travel, backpacking, etc."
  _="on keyup[key is 'Enter'] go to /checklists/{this.value}"
  enterkeyhint="send" />

According to the docs the url requires a stringlike rather than an expression. How would you handle this?

 go [to] url <stringLike> [in new window]
 go [to] [top|middle|bottom] [left|center|right] [of] <expression> [(+|-) <number> [px] ][smoothly|instantly]
 go back

https://hyperscript.org/commands/go/


Solution

  • go to requires expression, so you can handle this by using string extrapolation, just like you would with javascript:

    _="on keyup[key is 'Enter'] go to url `/checklists/${this.value}`"