4

I am writing Rmd files introducing the whisker package. And use slidify to compile it to html slides.

Therefore it is inevitable to use {{ and }} in the code. I wrote the following code in the Rmd file:

```{r}
tpl <- "
<b>Against:</b> {{x.against}}<br/>
<b>Venue:</b> {{x.venue}}<br/>
<b>Match:</b> {{x.type}}<br/>
<b>Score:</b> {{x.score}}<br/>
<b>Result:</b> <span class={{x.result}}>{{x.result}}</span><br/>
{{#x.sr}}<b>Strike Rate:</b> {{x.sr}} {{/x.sr}}
"
```

But in the parsed html file, the braces and the content inside are ignored:

<pre><code class="r">tpl &lt;- &quot;
&lt;b&gt;Against:&lt;/b&gt; &lt;br/&gt;
&lt;b&gt;Venue:&lt;/b&gt; &lt;br/&gt;
&lt;b&gt;Match:&lt;/b&gt; &lt;br/&gt;
&lt;b&gt;Score:&lt;/b&gt; &lt;br/&gt;
&lt;b&gt;Result:&lt;/b&gt; &lt;span class=&gt;&lt;/span&gt;&lt;br/&gt;

&quot;
</code></pre>

It is not convenient to directly write html in the Rmd file for codes. The option results='asis' in knitr is only affecting the output but not the code chunk.

Is there any solution to deal with {{ and }} in the code chunk? Thanks.

TomHall
  • 286
  • 3
  • 15

2 Answers2

2

Slidify expands all mustache tags by default. There is an undocumented feature that will allow you to pass these tags untouched. Here is a simple example

--- .RAW

Template

```{r}
{{ myvariable }}
```

So add the .RAW class property to the slide where you want this behavior.

Ramnath
  • 54,439
  • 16
  • 125
  • 152
0

What are you using to do your knitr stuff? I've just tested this in RStudio (which I've used to do all my Rmd stuff because it's super convenient) and I've not had this problem; I just copied your code and it come out including the stuff in double braces.

If you're not already using RStudio, try that?

Lucy
  • 1
  • Hi Lucy, I am very sorry that I forgot to notice I am trying to use `slidify` to make slides. I've updated the question. Thank you. – TomHall Jun 20 '14 at 10:50