Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Code formatting + Line continuation in Slim

I've been learning Slim lately and I was wondering if there's a way to format or beautify my code in it. I have been wary of using newlines(pressing Enter) because it causes errors.

The reason I want to format it is because most of my code can't fit the single line of my text editor and what usually happens is that it continues to the next line, which usually ends up to be unreadable for me.

This is usually in just one line:
li #{author.first_name} #{author.last_name} <a href="/">View</a><a href="/">Edit</a><a href="/">Delete</a>

Is there a way or a character to denote a line continuation? I want the links to used the next line so that it would be more readable for me.

like image 209
Panoy Avatar asked Mar 21 '13 03:03

Panoy


2 Answers

Your example can been broken into smaller parts:

li
  =#{author.first_name} #{author.last_name}
    a href="/" View
    a href="/" Edit
    a href="/" Delete
like image 26
three Avatar answered Sep 20 '22 02:09

three


You can also use an attributes wrapper to span multiple lines

div[id="#my-id"
  class="my-class" 
  data-author="George Washington"
  data-date="2013-08-21"]
like image 156
idrinkpabst Avatar answered Sep 18 '22 02:09

idrinkpabst