[wellwell-devel] [wellwell/zoom] Let [zoom] accept filters for HTML attributes.

Stefan Hornburg wellwell-devel at rt.icdevgroup.org
Mon Sep 6 12:18:08 UTC 2010


commit fa949c7c6d4a6ba116e69a723ab3e8caeaafd769
Author: Stefan Hornburg (Racke) <racke at linuxia.de>
Date:   Mon Sep 6 12:42:13 2010 +0200

    Let [zoom] accept filters for HTML attributes.

 lib/WellWell/Zoom.pm |   24 +++++++++++++++++++++++-
 1 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/lib/WellWell/Zoom.pm b/lib/WellWell/Zoom.pm
index f36ce46..32b3118 100644
--- a/lib/WellWell/Zoom.pm
+++ b/lib/WellWell/Zoom.pm
@@ -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";
@@ -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);
+							}
+						}
+					}
 				}
 			}
 	



More information about the wellwell-devel mailing list