Skip to content

Commit

Permalink
Fix issues with a usage of group variables and template varibaes toge…
Browse files Browse the repository at this point in the history
…ther
  • Loading branch information
melezhik committed Jul 12, 2024
1 parent bb6efc8 commit f9c94b7
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ Revision history for Sparky

{{$NEXT}}

- Fix issues with a usage of
group variables
and template varibaes
together

0.2.7 2024-06-14T13:30:00Z

- Huge overhaul of documentation
Expand Down
17 changes: 13 additions & 4 deletions bin/sparky-web.raku
Original file line number Diff line number Diff line change
Expand Up @@ -823,9 +823,18 @@ sub create-cro-app ($pool) {

}

my @group_vars = %project-conf<group_vars> || [];
my @vars;

for (%project-conf<vars><> || []).grep({$group ?? @group_vars.Bag $_<group><>.Bag !! True}) -> $v {
for (%project-conf<vars><> || []) -> $v {

if ($v<group> && %project-conf<group_vars><>.Bag $v<group><>.Bag) {
say "{$v<name>} group:{$v<group>} is added by group condition ...";
} else {
say "{$v<name>} group:{($v<group>||[]).perl} is filtered out by group condition ...";
next;
}

@vars.push($v);

if $v<default> {
for $v<default> ~~ m:global/"%" (\S+?) "%"/ -> $c {
Expand Down Expand Up @@ -908,15 +917,15 @@ sub create-cro-app ($pool) {
http-root => sparky-http-root(),
sparky-tcp-port => sparky-tcp-port(),
group_vars => $group ?? [] !! %project-conf<group_vars> || [],
render-vars => $group ?? True !! ( @group_vars ?? False !! True ),
render-vars => $group ?? True !! ( @vars.elems > 0 ?? True !! False ),
css =>css(),
navbar => navbar($user, $token),
project => $project,
allow-manual-run => %project-conf<allow_manual_run> || False,
disabled => %project-conf<disabled> || False,
project-conf-str => $project-conf-str || "configuration not found",
project-conf => %project-conf || {},
vars => (%project-conf<vars> || []).grep({$group ?? [$group].Bag $_<group><>.Bag !! True}) || [],
vars => @vars,
scenario-code => "$root/$project/sparrowfile".IO ~~ :e ?? "$root/$project/sparrowfile".IO.slurp !! "scenario not found",
error => $error
}
Expand Down
7 changes: 6 additions & 1 deletion templates/build.crotmp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@
<input class="input is-success" type="password" name="<$i.<name>>" value="<$i.<default>>" placeholder="<$i.<default>>">
</?>
<?{ $i.type eq 'textarea' }>
<?$i.default>
<textarea class="textarea is-success" cols=20 type="textarea" name="<$i.<name>>" placeholder="<$i.<default>>"><$i.<default>></textarea>
</?>
<!$i.default>
<textarea class="textarea is-success" cols=20 type="textarea" name="<$i.<name>>" placeholder=""></textarea>
</!>
</?>
<?{ $i.type eq 'checkbox' }>
<?$i.default>
Expand All @@ -56,7 +61,7 @@
<select name="<$i.<name>>">
</!>
<@$i.values: $s>
<?{ $i.default eq $s }>
<?{ $i.default && $i.default eq $s }>
<option selected="selected"><$s></option>
</?>
<!>
Expand Down

0 comments on commit f9c94b7

Please sign in to comment.