When rendering a .pdf.erb file to latex and the file contains non-html-safe parts, they get escaped in a way that would be suitable for HTML. However, we are generating LaTeX and not HTML, which means html_safe makes no sense in the first place (already the name says that).
Since the string produced by join is not html_safe, the generated String is "Anna", "Berta", which then causes LaTeX to crash because the & sign is not permitted.
The alterantive would be to use safe_join and raw instead:
<%= safe_join people.map{|person| raw "'#{person.label}'"}, ', ' %>
...or to tag the string as html_safe. However, it would be much more convenient, and also appropriate for the reasons described above, to skip HTML safety entirely when rendering LaTeX to PDF. Can this be achieved?
When rendering a .pdf.erb file to latex and the file contains non-html-safe parts, they get escaped in a way that would be suitable for HTML. However, we are generating LaTeX and not HTML, which means
html_safe
makes no sense in the first place (already the name says that).This is a problem in the following example:
Since the string produced by
join
is nothtml_safe
, the generated String is"Anna", "Berta"
, which then causes LaTeX to crash because the&
sign is not permitted.The alterantive would be to use
safe_join
andraw
instead:...or to tag the string as
html_safe
. However, it would be much more convenient, and also appropriate for the reasons described above, to skip HTML safety entirely when rendering LaTeX to PDF. Can this be achieved?