开发者

How to write this in haml?

开发者 https://www.devze.com 2023-02-19 17:36 出处:网络
What is that i should开发者_Go百科 write to convert this to haml When I tried like this %p We prefer questions that can be

What is that i should开发者_Go百科 write to convert this to haml

When I tried like this

%p
  We prefer questions that can be 
  %b answered
  . not just discussed.

I got Illegal element: classes and ids must have values error.

IS there any way i can get the dot not bolded.


This should work:

%p
  We prefer questions that can be 
  <b>answered</b>. not just discussed.

Edit

As @mark pointed out below the reason you were receiving the error was because if a line starts with a . haml is expecting a class name in order to render a div with that class.

\.

escapes the .


Mark's answer is still going to be the best, for readability.

You could do this in pure HAML by using the > operator on the b tag to remove surrounding spaces. However, you'd need to insert a non-breaking space before the bold word to keep it separate.

%p
  We prefer questions that can be&#160; 
  %b> answered
  \. not just discussed.


You need to escape the leading period as it's evaluating it as a div with a class.

%div.my_class 
== 
.my_class  
== 
<div class='my_class'></div>

%p
  We prefer questions that can be 
  %b answered
  \. not just discussed.
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号