devnacho/mountain_view

Ability to nest compontents

Closed this issue · 2 comments

Within the component haml template it would be great if you could nest other components (ex buttons within cards)

kitop commented

Hey @reubenmoes, you should be able to nest components by calling render_component inside a component template. Have you tried that?

@kitop Ah, that worked. I was using the wrong syntax. This worked

.card{:class => "#{'card--no-img' if properties[:image_url].nil?}"}
  - if properties[:image_url]
    .card__image
      %a{:href => properties[:link]}
        %img{:alt => properties[:title], :src => properties[:image_url]}/
  .card__content
    %h3.card__content__title
      %a{:href => properties[:link]}= properties[:title]
    - if properties[:description]
      %p= properties[:description]
    .card__content__data
      - if properties[:data] && properties[:data].any?
        - properties[:data].each do |data|
          %dl
            %dt= data[:number]
            %dd= data[:title]

  .card__comment
    =render_component("comment", {author: 'Saul', body: 'asdf', date: 'asdf'});