Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

punctuation after a link in ruby haml

Tags:

ruby

haml

I have this code:

%p
   A debtor with the court's approval can hire attorneys via
   %a{:id=>"proc",:href=>'/codes#rule327'}Section 327.

That renders:

A debtor with the court's approval can hire attorneys via Section 327.

I know this is extremely picky, but I do not want the period bolded. When I try:

%p
   A debtor with the court's approval can hire attorneys via
   %a{:id=>"proc",:href=>'/codes#rule327'}Section 327
   \.

It yields:

A debtor with the court's approval can hire attorneys via Section 327 .

I would like to know how do I get:

A debtor with the court's approval can hire attorneys via Section 327.

like image 443
shicholas Avatar asked Dec 15 '12 22:12

shicholas


2 Answers

HAML has helper methods specifically designed to "manipulate whitespace in a more precise fashion than what the whitespace removal methods allow."

There are three methods: surround, precede, and succeed, which provide better whitespace control. In your case, you can use the succeed helper like this to append the period after the link:

%p
  A debtor with the court's approval can hire attorneys via
  = succeed "." do
    %a{:id=>"proc",:href=>'/codes#rule327'}Section 327

See the HAML documentation under "Helper Methods".

like image 52
mayatron Avatar answered Oct 21 '22 04:10

mayatron


You can use the outer "space eater" (>) after the tag definition:

%p
  A debtor with the court's approval can hire attorneys via
  %a{:id=>"proc",:href=>'/codes#rule327'}>Section 327
  .

Manual reference

like image 45
ualinker Avatar answered Oct 21 '22 06:10

ualinker