Skip to content

Commit a0afe27

Browse files
authored
Merge pull request #31 from schneiderfelipe/patch-1
Make flat accept AbstractArray
2 parents 1fc13cc + 7108f4c commit a0afe27

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

src/Hyperscript.jl

+2-1
Original file line numberDiff line numberDiff line change
@@ -130,14 +130,15 @@ function processattrs(ctx, tag, attrs)
130130
)
131131
end
132132

133-
function flat(xs::Union{Base.Generator, Tuple, Array})
133+
function flat(xs::Union{Base.Generator, Tuple, AbstractArray})
134134
out = Any[] # Vector{Any} for node children and attribute values
135135
for x in xs
136136
append!(out, flat(x))
137137
end
138138
out
139139
end
140140
flat(x) = (x,)
141+
flat(x::AbstractRange) = (x,)
141142

142143
## Rendering
143144

test/runtests.jl

+2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ end
9090
## Generators, arrays, and tuples
9191
# Arrays are flattened
9292
@renders m("p", [1, 2, 3]) s`<p>123</p>`
93+
# AbstractArrays are flattened
94+
@renders m("p", BitArray([0, 1, 0])) s`<p>falsetruefalse</p>`
9395
# Generators are flattened
9496
@renders m("p", (x for x in 1:3)) s`<p>123</p>`
9597
# Tuples are flattened

0 commit comments

Comments
 (0)