> 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