Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

HTML

Using Jade & YAML with templates

I'm trying to use Jade with my templates in Jekyll and it's formatting the YAML into one line. This is my code in jade:

| ---    
| layout: default    
| title: Suljam | Designed with Standards    
| ---    
| {% include header.html %}    
section.whatcanwedo
  h2.feat.wow.fadeIn(data-wow-duration='1s', data-wow-delay='0.5s') What can we do for you buddy?
  img.featured.left(src='assets/img/suljam_3.jpg')
  img.featured.right(src='assets/img/suljam_6.jpg')

But it's out putting like this:

--- layout: default title: Suljam | Designed with Standards --- {% include header.html %}
<section class="whatcanwedo">
  <h2 data-wow-duration="1s" data-wow-delay="0.5s" class="feat wow fadeIn">What can we do for you buddy?</h2><img src="assets/img/suljam_3.jpg" class="featured left" /><img src="assets/img/suljam_6.jpg" class="featured right" />

instead of:

--- 
layout: default 
title: Suljam | Designed with Standards 
--- 
{% include header.html %}
<section class="whatcanwedo">
  <h2 data-wow-duration="1s" data-wow-delay="0.5s" class="feat wow fadeIn">What can we do for you buddy?</h2><img src="assets/img/suljam_3.jpg" class="featured left" /><img src="assets/img/suljam_6.jpg" class="featured right" />

You get the idea I hope. Basically does anyone know how I can get the YAML to format correctly from the Jade compiled into the HTML?

Many thanks

2 Answers

akak
akak
29,445 Points

Try this:

:verbatim
    ---
    layout: default
    title: Suljam | Designed with Standards
    ---
    {% include header.html %}

section.whatcanwedo
  h2.feat.wow.fadeIn(data-wow-duration='1s', data-wow-delay='0.5s') What can we do for you buddy?
  img.featured.left(src='assets/img/suljam_3.jpg')
  img.featured.right(src='assets/img/suljam_6.jpg')

Sadly that didn't work :( But thank you

akak
akak
29,445 Points

hm... and if you'd try to put the YAML in separate file - just these few lines - and just include in Jade?

It worked for me when I needed to include parts of normal HTML file into Jade... worth a shot, I guess :)

Yeah I was thinking this too akak but was hoping on a workaround rather than having another file. Thanks though :)