Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Let [zoom] accept filters for HTML attributes.
  • Loading branch information
racke committed Sep 6, 2010
1 parent a16fb33 commit fa949c7
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion lib/WellWell/Zoom.pm
Expand Up @@ -51,7 +51,9 @@ sub zoom {
}

if ($function eq 'display') {
my ($sref, $bref, $sql, $sth, $bind, %columns, $row, $key, $value, $lel, %paste_pos, $rep_str);
my ($sref, $bref, $sql, $sth, $bind, %columns, $row, $key, $value,
$att_name, $att_spec, $att_tag_name, $att_tag_spec, %att_tags, $att_val,
$lel, %paste_pos, $rep_str);

unless ($sref = $::Scratch->{zoom}->{$name}->{object}) {
die "Missing template $name\n";
Expand Down Expand Up @@ -117,6 +119,26 @@ sub zoom {
else {
$elt->set_text($rep_str);
}

# replace attributes on request
if ($value->{attributes}) {
while (($att_name, $att_spec) = each %{$value->{attributes}}) {
if (exists ($att_spec->{filter})) {
# derive tags from current record
if (exists ($att_spec->{filter_tags})) {
while (($att_tag_name, $att_tag_spec) = each %{$att_spec->{filter_tags}}) {
$att_tags{$att_tag_name} = $row->{$att_tag_spec};
}
}
else {
%att_tags = ();
}

$att_val = Vend::Interpolate::filter_value($att_spec->{filter}, undef, \%att_tags, $att_spec->{filter_args});
$elt->set_att($att_name, $att_val);
}
}
}
}
}

Expand Down

0 comments on commit fa949c7

Please sign in to comment.