[Masterview-users] Logging from within a directive [img element markup]

Deb Lewis
Sat, 10 Jun 2006 00:47:51 -0000

RE: mv:image_tag attribute notation and Ed''s remarks:

>> Currently, to support image sizes and other attributes, I am forced
>> to do this for all my image tags:
>> <img src="../../../public/images/my.gif"
height="17" width="16
>>      mv:image_tag="''my.gif'', :size =>
''17x16''">

Ed - we''ll probably have to think about that a bit before responding
further.

In the meantime, you might consider some alternative techniques approaches
using css style rules with your elements.

Option 1: if you have a small set of specific images that you use in a
number of places, consider defining a class in your css stylesheet for these
so you don''t have to hard-code the size attributes in the
markup.

    <img src="../../../public/images/my.gif" height="17"
width="16
         mv:image_tag="''my.gif'', :size =>
''17x16''" />

could be replaced with style rule and simplified markup:

    img.my-gif {  width: 16px;  height: 17px; }
    <img src="../../../public/images/my.gif"
class="my-gif"
         mv:image_tag="''my.gif'', :class =>
''my-gif''" />

(don''t like the need to duplicate the style rule class, but IMO
that''s still
a better than bolting down image file size attributes directly in content
pages)

Option 2: if you have a number of standard-sized images that you use
frequently, do a variation of the preceding with a style rule, say, some
name by ''visual-cue-img'', whatever makes sense.

And a possible option 3: create a custom masterview directive to encapsulate
a standard pattern than you want to use across a number of pages in our
site.

(I actually have a situation that #3 solves nicely in I''m doing right
now,
so after working out details will probably contribute it to the next
MasterView release as an example of how to do a custom masterview directive)

>>> So even <img src="../../../public/images/my.gif"
needs:
>>  mv:image_tag="''my.gif''"

Jeff - this might be interesting, let''s take a look at this case when
we
have a chance.  It''s quite similar to the target substitution magic
we''re
working on right now for mv:generate.  The template being processed already
provides some info about what the directive should produce and it would be
nice if the author didn''t have to repeat the image asset''s
name.  e.g. some
sort of mv:image="{this_src}" notation, if we can specify a sensible
rule
about how to determine the relevant portion of the tag''s
existing src
attribute to use in the generated output.

(?? mv:image_tag="{src_filename}" notation could work for images
directly
contained in the std rails public/images dir; not sure how far to push on
trying to automagically determine a relative path name w/in the images dir,
there are issues of nesting in the template src dir that make ugly .. paths
like the above tricky)

~ Deb