Deb Lewis
2006-Jun-12 21:05 UTC
[Masterview-users] Logging from within a directive [img element markup]
Ed - you''ve raised some good issues and ideas about where improvements in this whole area of specifying images. Some of this is very similar to the work we''re just now doing in the mv:generate mechanism, so that when you write a masterview template you don''t have to needlessly repeat information to get the desired output file name when there''s a reasonable mapping from the source template''s own name. As soon as we get the template generation name handling stuff settled, we can go back and look at providing equivalent simplification for asset references like images. One approach, per your description in your last message about what you''ve prototyped, is to be more clever in the mv:image_tag to make it smart enough to carry along attributes already specified in the template (class, style, width/height...). Seems like a good idea; we''d need to make sure we think through whether there''s any attributes that should *not* be picked up from the template''s <img> attributes or, say, if some exclude clause is needed. There''s also another approach I thought of over the weekend that might help simplify working with images. Recall your original case:> <img src="../../../public/images/my.gif" height="17" width="16" > mv:image_tag="''my.gif'', :size => ''17x16''" />Instead of trying to use the full mv:image_tag, which was forcing you to repeat both the image file ref and other attributes (in this case size info) that are needed by the underlying rails image_tag helper, we might just want a new directive mv:image_path (?mv:image_src?) which would operate like a variation of the general mv:attr directive that allows you to replace specified attribute values. Would look something like: <img src="../../../public/images/my.gif" height="17" width="16" mv:image_path="my.gif" /> where the semantics are "replace the value of the src attribute with the path to the image asset" and the directive implementation would run the mv:image_path''s attribute value through the standard rails image_path helper function. And then better yet would be a notation for the attribute value that in some fashion says "use the image name from what I already said in the src attribute", assuming we have some reliable way to infer subdir paths properly: <img src="../../../public/images/my.gif" height="17" width="16'' mv:image_path="{image_ref}" /> ~ Deb -----Original Message----- From: Ed Howland [mailto:ed.howland at gmail.com] Sent: Monday, June 12, 2006 10:22 AM To: djlewis at acm.org Subject: Re: [Masterview-users] Logging from within a directive [img element markup] On 6/12/06, Ed Howland <ed.howland at gmail.com> wrote:> So, in the end I modified image_tag and image_tag_link to parse out > the values from attr_lckv hash and just reformat those into an > image_tag helper call. Now it works great with explicit sizes and/or > class. > > Not magic enoops, hit the send button.. It is not magic enough to interpret the path relative to public/images. So if you have a subfolder to that, I can''t do it yet. But the possibility is there, since I am using Pathname which allows for some manipulation. Actually, I can just pass the subfolder as the argument to mv:image_tag and prepend it to the image_tag if it exists and is non zero length. Ed -- Ed Howland http://greenprogrammer.blogspot.com
Ed Howland
2006-Jun-12 22:01 UTC
[Masterview-users] Logging from within a directive [img element markup]
On 6/12/06, Deb Lewis <djlewis at acm.org> wrote:> > Instead of trying to use the full mv:image_tag, which was forcing you to > repeat both the image file ref and other attributes (in this case size info) > that are needed by the underlying rails image_tag helper, we might just want > a new directive mv:image_path (?mv:image_src?) which would operate like a > variation of the general mv:attr directive that allows you to replace > specified attribute values. Would look something like: > > <img src="../../../public/images/my.gif" height="17" width="16" > mv:image_path="my.gif" /> > > where the semantics are "replace the value of the src attribute with the > path to the image asset" and the directive implementation would run the > mv:image_path''s attribute value through the standard rails image_path helper > function. > > And then better yet would be a notation for the attribute value that in some > fashion says "use the image name from what I already said in the src > attribute", assuming we have some reliable way to infer subdir paths > properly: > > <img src="../../../public/images/my.gif" height="17" width="16'' > mv:image_path="{image_ref}" /> > > ~ DebWell, ok. So in these cases, do you infer somehow that the resulting tag is <%= image_tag("my.gif", :size => "17x16") just based on the appearance of he mv:image_path attribute? Ed -- Ed Howland http://greenprogrammer.blogspot.com