How do I put preformatted text into a FitNesse fixture table cell?
Asked Answered
F

5

9

I want to be able to put preformatted text (i.e. containing line breaks) into a single cell of a FitNesse fixture table. Is there a way to manipulate the FitNesse wiki markup to do this?

Flurry answered 25/10, 2008 at 10:3 Comment(0)
F
19

Use !- -! to get multiline table cells and {{{ }}} to get preformatted text. The {{{ has to be outside the !-

For example:

|sql|
|{{{!- SELECT *
     FROM bar
     WHERE gaz = 14
-!}}}|
Freemasonry answered 25/2, 2009 at 21:18 Comment(3)
Thanks. Note that the {{{ … }}} inserts <pre> … </pre>. This may not be what you want. I saw using setHeader / setHeaders in RestFixture. !- … -! was what was needed.Burgeon
This doesn't seem to work with FitNesse release 20130530; the cell value isn't formatted and and the curly brackets appear in the rendered page.Roux
This doesn't work if you want variable substitution within the formatted text!Cia
F
2

One way to do this is to define a variable with the multi-line text and then refer to this from the table cell:

!define sql {  SELECT *
  FROM bar
  WHERE gaz = 14
}

|sql|
|${sql}|
Flurry answered 25/10, 2008 at 10:31 Comment(1)
Hmmm... It seems to work. However I prefer your approach - I'll give it a try. Thanks.Flurry
R
1

richard's comment on Johannes Brodwall's answer worked for me, i.e. you don't need the "formatted 'as is'" line/block markup, just the "'as-is'/escaping" character formatting so the following is sufficient if you don't need or want the pre-formatted style too:

|sql|
|!-Some text
that spans
multiple lines.
-!|
Roux answered 29/8, 2014 at 15:57 Comment(0)
A
1

This way allows you to keep a table row on the same line in your source code :

| col1 | col2 |
| !- col1 cell <br /> with line break -! | col2 cell without line break |
Acherman answered 30/9, 2014 at 12:6 Comment(0)
C
1

The way that ended up working best for me was using a couple of the solutions listed above together. Defining a variable and using the !- -!

define myVarWithLineBreaks {!-This is my
text with line
breaks-!}

|col                   |col2       |
|${myVarWithLineBreaks}|other value|
Contrive answered 8/10, 2020 at 15:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.