DougBeney / jekyll-pug

Jekyll Plugin That Allows You To Use Pug
MIT License
37 stars 2 forks source link

Does forloop works? #1

Closed ghost closed 7 years ago

ghost commented 7 years ago

Hello!, I was using your plugin and cant figure out how to use forloops Thank you!

DougBeney commented 7 years ago

Hi, Juliso!

Thank you for trying out the plugin.

Can you provide some more detail on how far you've gotten so far? Any errors?

Forloops should definitely work.

Make sure to read the README carefully.

ghost commented 7 years ago

Doug thanks for the fast response! I was trying to do so:

ul
  {% for hello in site.hellos %}
    li {{ hello.title }}
  {% endfor %}

Because i just found out about this:

ul
  - for (var i=1; i<=10; i++) {
    li= i + ". Hello"
  - }   
DougBeney commented 7 years ago

Glad you figured it out.

If you ever need to use Jekyll's for loops, it is still possible. You just made a slight syntax error.

Here is the correct code:

ul
    | {% for hello in site.hellos %}
    li {{hello.title}}
    | {% endfor %}

The | signals piped text. Here's some info on how Pug's piped text works

How this plugin works is it first converts the Pug code to HTML and then uses Jekyll's HTML compiler to deal with the template engine code.

Hope you enjoy this plugin and do let me know if you have any other questions!

Cheers.