V
V
Vyacheslav Lebedev2015-07-08 03:40:41
Pug
Vyacheslav Lebedev, 2015-07-08 03:40:41

How to make Jade and Spacebars (Handlebars) friends?

Greetings!
I can’t figure out how to fix the code so that everyone likes everything and compiles properly :)
Here is the code:

template(name="postsList")
  .posts.
    {{#each posts}}
      {{> postItem}}
    {{/each}}

Accompanying error:
While building the application:
   client/views/posts/posts_list.jade: Jade syntax error: Expected {{else}} or block close for each
   {{#each posts}}

OK. I do it like this:
template(name="postsList")
  .posts {{#each posts}} {{> postItem}} {{/each}}

Hooray! App running at.
I wouldn't want to leave it like this.
So what doesn't Jade like?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vyacheslav Lebedev, 2015-07-13
@slavikse

Answer to the question :

template(name="postsList")
  .posts
    each posts
      +postItem

Found right here .

K
Konstantin Kitmanov, 2015-07-08
@k12th

Recently encountered a similar problem (Jade + Ractive).
He doesn't like each, he thinks it's Evonian, Jade each.
You can fix it the way you did, or like this:

template(name="postsList")
  .posts
    | {{#each posts}}
    |  {{> postItem}}
    | {{/each}}

I have not found a nicer way, unfortunately.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question