JuliaWeb / JuliaWeb/Hyperscript.jl

Feature request: do-block syntax

Open
#32 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Julia
Stars
105
Forks
12
PR merge metrics
No merged PRs in 30d

Description

Hi @yurivish, how do you feel about adding a **do-block syntax** (similar to [markaby](https://github.com/markaby/markaby))? That would allow one to write the following:

```julia
using Hyperscript

@tags div em a

# What I'm proposing:
div.header() do
a(href="https://github.com/yurivish/Hyperscript.jl") do
em("Hyperscript.jl")
end
end
```

instead of

```julia
# Current equivalent:
div.header(a(href="https://github.com/yurivish/Hyperscript.jl", em("Hyperscript.jl")))
```

or, equivalently,

```julia
# Indented current equivalent:
div.header(
a(href="https://github.com/yurivish/Hyperscript.jl",
em("Hyperscript.jl")
)
)
```

That could increase readability in general. Of course, nothing would break; it would only be an alternative way of writing things.

If you like it, I could make a PR 😀

**EDIT**: a single line is all that's required to make the example above work:

```julia
julia> (x::Hyperscript.Node)(f::Function, args...; props...) = x(args..., f(); props...)

julia> div.header() do
a(href="https://github.com/yurivish/Hyperscript.jl") do
em("Hyperscript.jl")
end
end


```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.