Google Mail Calendar Documents Reader Web more »
Recently Visited Groups | Help | Sign in
Google Groups Home
Image link syntax
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  4 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Follow-up To:
Add Cc | Add Follow-up to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers that you hear
 
Chap  
View profile   Translate to Translated (View Original)
 More options 31 Mar, 16:35
From: Chap <c...@chap.otherinbox.com>
Date: Tue, 31 Mar 2009 08:35:17 -0700 (PDT)
Local: Tues 31 Mar 2009 16:35
Subject: Image link syntax
What's the syntax for having an image link?

I tried:
    = link = img "question_sense_logo.png", "http://
www.questionsense.com"

But finally just did:
    %a{:href => "http://www.questionsense.com"}
      = img "question_sense_logo.png"

Is this the prettiest way?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Abraão Coelho  
View profile   Translate to Translated (View Original)
 More options 31 Mar, 17:33
From: Abraão Coelho <abrcoe...@gmail.com>
Date: Tue, 31 Mar 2009 13:33:16 -0300
Local: Tues 31 Mar 2009 17:33
Subject: Re: Image link syntax

Yeap, I guess that's it... Maybe you can create a helper to make it
prettier, something like "link_to_image :link, :image"...

How's that sound? =)

---
Abraão Coelho 
Blog: http://abrcoelho.net
Twitter: @abrcoelho
Belo Horizonte - MG


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Joshaven Potter  
View profile   Translate to Translated (View Original)
 More options 31 Mar, 19:13
From: Joshaven Potter <yourt...@gmail.com>
Date: Tue, 31 Mar 2009 14:13:58 -0400
Local: Tues 31 Mar 2009 19:13
Subject: Re: Image link syntax

you don't need the double = in the line... its actually bad... also you need
to use ()'s so the parser knows what attrabutes go to which helper...   Your
first example is actually sending the "img" helper two arguments, the image
and the url and assigning them to link.  You actually want to send the
output of the image helper and the url to the link helper.

This should work:
= link( img("question_sense_logo.png"), "http://www.questionsense.com")
which is the same as:
= link img("question_sense_logo.png"), "http://www.questionsense.com"

I didn't find an API on what the link helper is expecting but it looks like
the first attribute is the innerHTML of the a tag and the second parameter
is the href.  It is possible that the link helper does not support the
output of the img helper as the first argument but I doubt it.

If that doesn't work then this will work:
%a{:href=>"http://www.questionsense.com"}= img("question_sense_logo.png")

For good measure you should add alt and title attributes to your anchor tag.
%a{:href=>"http://www.questionsense.com", :alt=>"Question Sense",
:title=>"QuestionSense"}= img("question_sense_logo.png")

(These attributes will be friendly with blind viewer programs and give the
browser something to display if the image is not avilable etc... Also I
believe the html validator at W3C <http://validator.w3.org/> will not pass
you without an alt attribute.)

To help your understanding of whats going on with the haml parcer:
= tells the remainder of the line to be evaluated as ruby code and the
output replaces the line (useful for variables etc)
- tells the remainder of the line to be evaluated as ruby code with no
output  (useful looping, variable assignments, etc)
%tag_name{} (where tag can be something like "a" "div" etc) the tag and
following optional hash is evaluated as ruby code.  The remainder of the
line will be considered text unless you have an = after the tag_name in
which case the remainder of the line is evaluated

These three examples would output the same thing

1)
  Hello World
2)
  = "Hello World"
3)
  - some_variable="Hello World"
  = some_variable

Note in the third example that there is an = sign... this is used as an
assignment which is the useual use of = in ruby.
The following would also output hello world but is kind of silly... I am
using it only to show you what the second equal sign does:
4)
  = some_variable = "Hello World"

This line sets 'some_variable' to the value of 'Hello World' and outputs the
value of 'some_variable' as text to the page from the first equal sign.  It
is exactly the same as option three but done in one line.

It will be worth your time to read up on "haml"

On Tue, Mar 31, 2009 at 11:35 AM, Chap <c...@chap.otherinbox.com> wrote:

> What's the syntax for having an image link?

> I tried:
>    = link = img "question_sense_logo.png", "http://
> www.questionsense.com"

> But finally just did:
>    %a{:href => "http://www.questionsense.com"}
>      = img "question_sense_logo.png"

> Is this the prettiest way?

--
Sincerely,
Joshaven Potter

"No man making a profession of faith ought to sin, nor one possessed of love
to hate his brother. For He that said, “Thou shalt love the Lord thy God,”
 said also, “and thy neighbor as thyself.”  Those that profess themselves to
be Christ’s are known not only by what they say, but by what they practice.
“For the tree is known by its fruit.”" -- Ignatius


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Chap  
View profile   Translate to Translated (View Original)
 More options 1 Apr, 13:27
From: Chap <c...@chap.otherinbox.com>
Date: Wed, 1 Apr 2009 05:27:47 -0700 (PDT)
Local: Wed 1 Apr 2009 13:27
Subject: Re: Image link syntax
Thanks everybody, looks like this is the cleanest way:
= link img("question_sense_logo.png"), "http://www.questionsense.com"

Joshaven, this automatically assigns the alt="Question sense logo",
pretty handy

On 31 Mar, 14:13, Joshaven Potter <yourt...@gmail.com> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message, you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google