Search code examples
ruby-on-railsrubyyamlmiddleman

Using Yaml attributes within Haml files for Middleman


I've created a middleman app and am attempting to use Yaml attributes within my Haml files and am having no success. Here's my very simple code:

\---
title: This is my title
\---

/ This is my paragraph
%p Hello world! This is = current_article.title

However, the above only generates this:

--- title: This is my title ---
Hello world! This is = current_article.title

I tried the answer from this question but it doesn't work. Can anyone tell me what I've overlooked or am missing.


Solution

  • In haml you must use #{} to display variables, try:

    \---
    title: This is my title
    \---
    
    / This is my paragraph
    %p Hello world! This is #{current_article.title}