How to disable HTML characters executed in whisker.render file in R

Package whisker

whisker.render("& Hello {{place}}", list("place" = "&World")) 

And the result:

[1] "& Hello &World"

The question arises: how to disable the escaping of HTML codes? For the code above to produce:

[1] "& Hello &World"
+4
source share
2 answers

Just use a triple mustache to avoid shielding.

whisker.render("& Hello {{{ place }}}", list("place" = "&World"))
+4
source

From the mustache documentation:

template <-
’Hello {{name}}
You have just won ${{value}}!

So, I tried this:

whisker.render("& Hello &{{place}}", list("place" = "World!"))

And I got a conclusion like:

[1] "& Hello &World!"

New approach:

I tried this:

y <-whisker.render("& Hello {{place}}", list("place" = "&World"))

Result for this:>

y
[1] "& Hello &amp;World"

Then I used the gsub function on y, like this:

> gsub("&amp;", "&", y)
[1] "& Hello &World"

which gave the above conclusion.

Instead of storing the value in a separate line, I applied gsub to the whisker function:

gsub("&amp;", "&", whisker.render("& Hello {{place}}", list("place" = "&World")))

, .

+1

All Articles