Problem with indentation when displaying javascript code in views

174 views
Skip to first unread message

Szymon Nowak

unread,
Dec 6, 2011, 5:18:33 AM12/6/11
to ha...@googlegroups.com
Hi,

I'm trying to display js snippet in my view using :escaped filter. I've got HTML similar to this:

%div
  %pre
    %code
      :escaped
        <script>
          var a = 1;
        </script>

There are 2 issues: 
1. How can I display this snippet so it won't be indented? Nesting it deeper in more HTML tags makes it more and more indented. 
2. The first line is actually not indented at all, but all others are. I have to manually move the first line by adding few spaces on the left, so that its indentation would match the other lines.

Cheers,
Szymon

Nathan Weizenbaum

unread,
Dec 6, 2011, 3:27:39 PM12/6/11
to ha...@googlegroups.com
You need to use the #preserve helper: https://gist.github.com/1439820

--
You received this message because you are subscribed to the Google Groups "Haml" group.
To view this discussion on the web visit https://groups.google.com/d/msg/haml/-/mvPF2VygAxIJ.
To post to this group, send email to ha...@googlegroups.com.
To unsubscribe from this group, send email to haml+uns...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/haml?hl=en.

Szymon Nowak

unread,
Dec 7, 2011, 6:10:46 AM12/7/11
to ha...@googlegroups.com
Thanks! 

I was trying to use preserve as a filter like this:

:preserve
  :escaped
    <script>
    </script>

but it printed out only ":escaped" :)
Reply all
Reply to author
Forward
0 new messages