开发者

how to render a helper

开发者 https://www.devze.com 2023-04-06 11:58 出处:网络
I\'ve built a helper which returns the string which I supposed to insert into HTML. I\'m using Haml, so html.haml file has this line:

I've built a helper which returns the string which I supposed to insert into HTML. I'm using Haml, so html.haml file has this line:

= build_filetree 'small'

It rendered the result into this:

<ul class="filetree"><li><span class="folder">
folder</span></li><ul><li><
span class="file">nested_file1.rb</span></li><li><
spanclass="file">nested_file2.rb</span></li></ul><
li><span class="file">file1.rb</span></li><li>
<span class="file">file2.rb</span></li></ul>

But I expected this:

<ul class="filetree">
  <li><span class="folder">folder</span></li>
  <ul>
    <li><span class="file">nested_file1.rb</span></li>
    <li><span class开发者_JAVA技巧="file">nested_file2.rb</span></li>
  </ul>
  <li><span class="file">file1.rb</span></li>
  <li><span class="file">file2.rb</span></li>
</ul>

What is the problem and how to fix it? Thanks


Just use raw helper. For example:

raw(“<ul class="filetree">...</ul>”)
0

精彩评论

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