开发者

When using HAML, is there a way to use heredoc or %Q{ ... }?

Maybe it can be put into a helper but the existing 500 lines of code has everything in the HAML code, so i开发者_StackOverflow社区t is better to follow the existing code for the moment (for tight deadlines).

I found the only way working right now is

- meta_tag = %Q{\n |
  <meta ...>\n |
  <meta ...>\n |
    [...]   \n |
  } |

which is to use the "continuation character" and the \n at the same time. It'd be great if it can be simplified.


A good way to do this would be to use the :ruby filter or load the needed content into a Ruby variable and pass it into HAML the normal way.


I think this is what "the Tin Man" meant.

:ruby                                                                                                                                                                                        
  text =<<-EOT                                                                                                                                                                               
  Hi,                                                                                                                                                                                        
    Please find some heredoc text                                                                                                                                                            
      right here                                                                                                                                                                             

  Bye                                                                                                                                                                                        
  EOT                                                                                                                                                                                        

%pre=text                                                                                                                                                                                    

I could not add this as a comment to his post, sorry!

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜