Issue with javascript expressions in edge templates


I’m trying to display the current year on my email edge template. I have this © {{ (new Date()).getFullYear() }} {{ appName }} in my email edge template but I get InvalidExpressionException: E_INVALID_EXPRESSION: Invalid expression < (new Date()).getFullYear() >

How do I fix this?


Why not simply say new Date().getFullYear(). I don’t see any need of wrapping new Date() inside braces


That’s how I wrote it initially but I wrapped new Date() in braces when I got E_INVALID_EXPRESSION: Invalid expression < new Date().getFullYear() >


Why can’t edge interpret new Date().getFullYear()?


@virk I’ve still not been able to get edge to render new Date().getFullYear(). I still get E_INVALID_EXPRESSION: Invalid expression < new Date().getFullYear() >. Any idea why this happening and a way around it?


As far as i know i dont think you can write “any” js code inside {{}}. (@virk could correct me if i’m wrong about it) .
As an alternative what you can do is :

  • Just pass the current year as data to the email template and then use {{currentYear}} inside the template
  • Create a view global (you can read more about it here Adonis View Globals)


Works fine. Thanks


I also get error here,

my javascript string format can’t