mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Add optional count to sample group
This commit is contained in:
parent
311b4b0f2f
commit
3d37a94aaf
1 changed files with 6 additions and 2 deletions
|
@ -26,7 +26,7 @@ module Spectator
|
|||
context({{what}}) {{block}}
|
||||
end
|
||||
|
||||
macro sample(collection, &block)
|
||||
macro sample(collection, count = nil, &block)
|
||||
{% name = block.args.empty? ? :value.id : block.args.first.id %}
|
||||
|
||||
def %collection
|
||||
|
@ -34,7 +34,11 @@ module Spectator
|
|||
end
|
||||
|
||||
def %to_a
|
||||
%collection.to_a
|
||||
{% if count %}
|
||||
%collection.first({{count}})
|
||||
{% else %}
|
||||
%collection.to_a
|
||||
{% end %}
|
||||
end
|
||||
|
||||
class Context%sample < {{@type.id}}
|
||||
|
|
Loading…
Reference in a new issue