Paragraph continuation with links

66 views
Skip to first unread message

BeeRich33

unread,
Jan 13, 2015, 10:35:10 PM1/13/15
to ha...@googlegroups.com
Hi folks.  Ran into something that breaks my server.  Turns out it's the HAML.  

Can someone provide some quick syntax for a paragraph that has a link inside the text?  I've tried new lines, and it 

Also, how can I break a paragraph without soft wrapping it?  

Cheers

BeeRich33

unread,
Jan 14, 2015, 10:04:35 AM1/14/15
to ha...@googlegroups.com
Oops, didn't finish that sentence.  "...and it..." doesn't seem to work.  

I'm new to this markup.  

Thanks

engineerDave

unread,
Jan 14, 2015, 10:12:27 AM1/14/15
to ha...@googlegroups.com
a rails helper link? surround the haml similar to string interpolation. 

%p This is a valid haml paragraph with a #{link_to 'link', some_url}

or 

%p 
  This is a valid haml paragraph with a 
  = link_to 'link', some_url

Or just a straight up link

%p 
  This is a valid haml paragraph with a 
  %a{href=some_url} Link

BeeRich33

unread,
Jan 14, 2015, 2:06:15 PM1/14/15
to ha...@googlegroups.com
Hi there.  It's not rails and no helper. 

Will give that last one a try. I tried something similar but will give it another shot.  Thanks.  

David Southard

unread,
Jan 14, 2015, 3:11:10 PM1/14/15
to ha...@googlegroups.com
addendum for the last link that should be   %a{href: some_url} Link

--
You received this message because you are subscribed to the Google Groups "Haml" group.
To unsubscribe from this group and stop receiving emails from it, send an email to haml+uns...@googlegroups.com.
To post to this group, send email to ha...@googlegroups.com.
Visit this group at http://groups.google.com/group/haml.
For more options, visit https://groups.google.com/d/optout.

BeeRich

unread,
Jan 16, 2015, 12:38:16 PM1/16/15
to ha...@googlegroups.com
OK, this is where I’m having problems:

%footer
%strong
©
{Time.now.year}
%a{href="http://sample.com", target="_blank"} Sample.com

It’s throwing an ISE on a join.

> On Jan 14, 2015, at 10:12 AM, engineerDave <nacen...@gmail.com> wrote:
>
> %p
> This is a valid haml paragraph with a
> %a{href=some_url} Link



bee...@gmail.com



Matt Wildig

unread,
Jan 16, 2015, 2:08:50 PM1/16/15
to ha...@googlegroups.com

> OK, this is where I’m having problems:
>
> %footer
> %strong
> ©
> {Time.now.year}

I think you want `#{Time.now.year}` here (i.e. you need the hash). You could probably put this on the same line as the one above, like this:

© #{Time.now.year}

> %a{href="http://sample.com", target="_blank"} Sample.com

Your syntax for the `a` tag there is wrong. You need either to make it look like a valid Ruby hash:

%a{:href=>"http://sample.com", :target=>"_blank"} Sample.com

(i.e. replace = with => and make the keys symbols (or strings))

or use the HTML style syntax (<http://haml.info/docs/yardoc/file.REFERENCE.html#htmlstyle_attributes_>):

%a(href="http://sample.com", target="_blank") Sample.com

(i.e. use () instead of {})

> It’s throwing an ISE on a join.

Is this using Sinatra? There’s an issue using Sinatra with the latest Rack (1.6) where the development exception handler throws an exception trying to call `join` on a string. If that is the case try pinning Rack to the latest 1.5 version for now (until a new Sinatra version is released). This won’t fix your actual issue, but will prevent it from being obscured by the Sinatra/Rack bug.

More generally, Haml isn’t very good at inline tags like this. This example should probably work okay, but it involves breaking up your code in an awkward way to get the newlines in the right places. Also you will have trouble when you want to add punctuation immediately after a tag. Check out the FAQ entry about it: <http://haml.info/docs/yardoc/file.FAQ.html#q-punctuation>. I would usually use something like the markdown filter here, although that might be tricky to get working with the `target` attribute. Your best bet might be to just use inline HTML for this link.


Matt

BeeRich

unread,
Jan 20, 2015, 2:09:52 PM1/20/15
to ha...@googlegroups.com
Hi there. Thanks for the reply.

OK I see what you mean about {} vs (). But I’ve taken out the link for now to see what I can accomplish with the Time.now.year. It’s still throwing the join error with:

%strong= © #{Time.now.year} Alpha Company

and

%strong= © '#{Time.now.year}’ Alpha Company

What I’ve done is this:

%strong= ["©", Time.now.year, “Alpha Company"].join(" “)

As for inline HTML, can I embed that into HAML to get around the restrictions? How HAML doesn’t handle inline links is a bit strange considering it’s meant to save time and remain flexible.

Cheers
bee...@gmail.com



Matt Wildig

unread,
Jan 20, 2015, 3:10:43 PM1/20/15
to ha...@googlegroups.com

> It’s still throwing the join error with:

Did you try pinning Rack? If you are getting the error I’m thinking of doing that should at least give you more informative error messages (I think there should be a new Sinatra soon too, so keep a look out).

> %strong= © #{Time.now.year} Alpha Company

You don’t need the =, just:

%strong © #{Time.now.year} Alpha Company

> As for inline HTML, can I embed that into HAML to get around the restrictions?

Yep, you can do something like this:

%strong © #{Time.now.year} <a href="wherever" target="_blank">Alpha Company</a>

> How HAML doesn’t handle inline links is a bit strange considering it’s meant to save time and remain flexible

True, but as the FAQ says: “Expressing the structure of a document and expressing inline formatting are two very different problems. Haml is mostly designed for structure”.


Matt

BeeRich

unread,
Jan 20, 2015, 3:34:03 PM1/20/15
to ha...@googlegroups.com
HI Matt. Thanks for the reply.

> On Jan 20, 2015, at 3:10 PM, Matt Wildig <ma...@mattwildig.co.uk> wrote:
>
>>
>> It’s still throwing the join error with:
>
> Did you try pinning Rack? If you are getting the error I’m thinking of doing that should at least give you more informative error messages (I think there should be a new Sinatra soon too, so keep a look out).

No clue what that means, pinning Rack. I’m new to all this stuff, btw.

>> %strong= © #{Time.now.year} Alpha Company
>
> You don’t need the =, just:
>
> %strong © #{Time.now.year} Alpha Company

OK that worked. Is there a way of shoving the link in there?

>> As for inline HTML, can I embed that into HAML to get around the restrictions?
>
> Yep, you can do something like this:
>
> %strong © #{Time.now.year} <a href="wherever" target="_blank">Alpha Company</a>

OK, just wondering if there is a way to stick in HAML though.

>> How HAML doesn’t handle inline links is a bit strange considering it’s meant to save time and remain flexible
>
> True, but as the FAQ says: “Expressing the structure of a document and expressing inline formatting are two very different problems. Haml is mostly designed for structure”.

OK, fair enough.

Hey thanks for the guidance. I’m there, pretty much. Heh.

Cheers


bee...@gmail.com



Matt Wildig

unread,
Jan 20, 2015, 3:39:48 PM1/20/15
to ha...@googlegroups.com

> No clue what that means, pinning Rack. I’m new to all this stuff, btw.

Are you using Bundler? If so add

gem 'rack', '1.5.2'

to your Gemfile. If not, use that same line somewhere in your code before you require anything. This will make your app use the previous version of Rack, before the change that is causing this error.


Matt

BeeRich33

unread,
Jan 20, 2015, 4:08:34 PM1/20/15
to ha...@googlegroups.com
Everything is working fine now.  I resorted back to html links and such.  

Cheers
Reply all
Reply to author
Forward
0 new messages