문제

Currently I have backbone RIA with rails backend. I'm using haml_coffee_assets gem for client-side templating. But I miss rails view helpers there.

I decided to add raw html strings into my backbone models. So, I have this kind of object in my coffeescript

Object
  avatar: "/avatars/small/missing.png"
  avatar_link: "<a href="/users/ortepko" class="author" id="user-nick-76"><img src="/avatars/small/missing.png" width="32" /></a>"
  humanized_messages_number: "1 Message "
  id: 76
  login_name_link: "<a href="/users/ortepko" class="author" id="user-nick-76">ortepko</a>"

my template code becomes pretty simple

.text_content
  .comment
    = @contact.avatar_link
    .text
      = @contact.login_name_link
      .messages
        %a{href: '#'}
          = @contact.humanized_messages_number

Now I want to render a template

JST['messages/yet_another_template'] {contact: contact}

But it does not seem to be working.

도움이 되었습니까?

해결책

I have found an answer here: Partials in Coffee HAML (.hamlc)

My Template should look like

.text_content
  .comment
    != @contact.avatar_link
    .text
      != @contact.login_name_link
      .messages
        %a{href: '#'}
          = @contact.humanized_messages_number

Thanks to Netzpirat!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top