Is there a handlebar way to break lines after each {{#each}} in markdown?

62 Views Asked by At

I have a JSON dataset which I pass through handlebars to generate .md files, something like this:

{{#each items}}| **{{name}}** | {{system.d.v}} | {{system.a.v}} | {{system.p}} |{{/each}}

... and I want to break lines after every single {{/each}}. One of many things I tried was this:

{{#each things}}| **{{name}}** | {{system.d.v}} | {{system.a.v}} | {{system.p}} |</br>{{/each}}

The thing is: the output is markdown (tried \n and ASCII as well) but I am not able to break lines, the output is a single very long line like | data | data | data |<br/>| data | data | data |<br/>| data | data | data |<br/>| data | data | data |<br/>| data | data | data |<br/>| data | data | data |<br/>| data | data | data |<br/>| data | data | data |<br/>| data | data | data |<br/>|

... and instead should look like this for example:

| name | data  | data  | data  |
| name | data  | data  | data  |
| name | data  | data  | data  |
| name | data  | data  | data  |
| name | data  | data  | data  |
| name | data  | data  | data  |

I searched here with no success, tried different helpers and ways to type , from ASCII to HTML and now I feel like in a dead end. User-software to display result is obsidian.md but it does not matter as far as the plain text gets printed in a single line. CSS or HTML does not solve the thing because it have to be a plain, seperated lines for markdown.

Please help me :3

2

There are 2 best solutions below

0
wendigo On BEST ANSWER

[solved] it by altering my earlier tries in the handlebar helper, it works now with:

Handlebars.registerHelper('breakline', function(text) {
    text = "\n";
    return text;
});

and calling it by the following in the markdown template:

{{#each things}}| **{{name}}** | {{system.d.v}} | {{system.a.v}} | {{system.p}} |**{{{breaklines test}}}**{{/each}}
3
Klas On

Try to add \n character for a line break instead of br tag, ore set br tag in quote marks.

{{system.p\n}}

"
"