wicked_pdf
wicked_pdf copied to clipboard
How to call a function inside the pdf
I am trying to call a function defined inside the pdf.erb in the script tag which converts the date to a specific format.
<script type="text/javascript"> function format_date(yyyyMMdd) { const [yyyy, MM, dd] = yyyyMMdd.split('-') // +dd is equal to Number.parseInt(dd, 10) return
${Number.parseInt(MM, 10)}/${+dd}/${yyyy.slice(2)} } </script>
The line that I'm trying to call this function is this
<td class="pan" style="background:none repeat scroll 0 0 #989694;width: 50px">format_date(<%=date%>)</td>
But in the pdf it renders like format_date(29-01-2020). The function is not being called it is acting like a text.