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 <- "
<b>Against:</b> <br/>
<b>Venue:</b> <br/>
<b>Match:</b> <br/>
<b>Score:</b> <br/>
<b>Result:</b> <span class=></span><br/>
"
</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.
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.