Can i place @each loop in one line?


#1

So i recently working a lyrics generator website with adonis js and i’m getting a strange issues with the @each loop in my text area. Here is my code.

<textarea class="form-control" name="lyrics" id="textareaId" rows="5" id="comment" style="margin-top:20px; font-family: Segoe UI; min-height:1500px;font-size: 25px; font-family: Helvetica;" required> 
    @each(lyric in lyrics) 
        {{lyric.lyric}} 
    @endeach 
</textarea>

So I’m getting multiples results from my controller, and I would like to add all of them to the text box. The problem I have this indentation.

i’ve tried to make @each in one line but im getting this text in my textarea

@each(lyric in lyrics) undefined @endeach

Any ideas?


#2

How about this?

<textarea class="form-control" name="lyrics" id="textareaId" rows="5" id="comment" style="margin-top:20px; font-family: Segoe UI; min-height:1500px;font-size: 25px; font-family: Helvetica;" required> 
@each(lyric in lyrics) 
{{lyric.lyric}} 
@endeach 
</textarea>

#3

Thanks virk it works!

But in case when i want to edit the lyrics i have to erase \r before inputting my data to the database. cuz if i’m not erasing \r the text area the view will be showed like this :

But still, thank you for solving my problem. Really love your framework by the way :grin:

maybe on the next version of adonis js you can add the one-line @each loop on the edge view for us :joy:

Hope this problem can help other people who have the same problem like me! Thanks!