wesbos
wesbos

Reputation: 26317

Output Multi line html with slim

I'm looking to output blocks of example HTML but I can't figure out how to do it with slim's syntax

At the end of the day, I want a pre tag with mutliple lines of code in it. Looking like this:

<pre>
Heading 3 is <h3>
Heading 2 is <h2>
</pre>

I've figured out that I can do:

pre= "Heading 3 is <h3>"

And the output shows the HTML code, rather than parsing it.

but multiple lines do not work. Any Ideas?

Upvotes: 1

Views: 3846

Answers (2)

Tijn
Tijn

Reputation: 157

There is a way to do this in Slim without using an embedded engine. The solution is to start the first line with a pipe (|) and indent all subsequent lines. (But don't prepend those with a pipe!) This is the way to keep Slim from concatenating all your lines of code.

Something like this:

pre
  | Heading 3 is <h3>
    Heading 2 is <h2>
    Heading 1 is <h1>

Upvotes: 2

LightGuard
LightGuard

Reputation: 5378

Might I suggest using an embedded engine for that?

doctype 5
html
  head
    title Testing
  body
    h1 Testing
    p Here's some output for you
    asciidoc:
      ```
      Testing <h1> 
      Testing <h2> 
      Testing <h3> 
      ```

Upvotes: 2

Related Questions