Search code examples
middleman

Consuming markdown inside yaml


I'm doing my first website with middleman and it's raising up some questions for me. One of which is if this is acceptable or/and the right approach.

My site ir organized like so:

data
  about.yml
  carrer.yml
  ...
source
  en
    about
      index.html.erb
    career
      index.html.erb
  ...
config.rb
GemFile
Gemfile.lock

I wish to consume the .yml from my html.erb file so inside my yaml have this:

pt:
    slides:
      - url: "/images/url.png"
        markdown: "#Heading One"

      - url: "/images/url.png"
        markdown: "#Heading One"

      - url: "/images/url.png"
        markdown: "#Heading One"
en:
    slides:
      - url: "/images/nocturna_new_lisbon_bridge_2.jpg"
      ---
      markdown:
      #Heading Oness
      ####Heading Four
      ---

      - url: "/images/url.png"
        markdown: "#Heading One"

      - url: "/images/url.png"
        markdown: "#Heading One"

No problem on my pt version but how can I get to make a more complicated markdown like on the en version? It doesn't work...

Finally on my index.html.erb I have somewhere in the page:

            <% data.homepage_carousel.en.slides.each_with_index do |f, index| %>
                <div class="item <%='active' if index == 0 %>" style="background-image:url(<%= f.url %>)">
                    <div class="carousel-caption">
                        <%= markdown f.markdown %><!-- CALLING HELPER-->
                    </div>
                </div>
            <% end %>

And that is ok...


Solution

  • Looks like this would do it:

    en:
        slides:
          - url: "/images/nocturna_new_lisbon_bridge_2.jpg"
            markdown: >
              #Heading Oness
    
    
              ####Heading Four
    
    
    ...
    

    The extra-lines ad spaces were what I was looking for as well as the > at the beginning of the var.