-
Notifications
You must be signed in to change notification settings - Fork 966
Handlebars if statement #3911
Comments
Hi @DanielMoreno58 can you share a code snippet from your transactional email? It would help to reproduce the issue. |
I am guessing there is something wrong with the v3 payload you provided. Here is an example payload:
Often time issues like this are best handled by support, but lets see if we can help you out. Can you share the v3 payload you were using and remove any sensitive information as needed. Also if we can get the template ID we can take a look and see what you have setup. |
@DanielMoreno58 - for future reference, you can file a ticket with our awesome support team by logging in at https://support.sendgrid.com/hc/en-us |
Okey, what I wanted to say is that the if conditional doesn't work with the handlebars in a transactional email (in the editor online), I cannot shared the code because I don't have the access right now, but I think there is an issue in there, I will try to create a free account and tried to reply the error. |
Let me know if you have any issues with creating an account. I'll do what I can to move things along. I just want to make sure we get the information we need if we do indeed have a bug. Thanks for your effort in helping with this. |
I'm new at this, but have you tried using < p >? It might work instead of the slashes. |
I am going to close this, but please feel free to continue the convo folks! |
@ksigler7 I'm encounter this as well, when doing something like the following:
I get an error that the template is invalid, when I open the code again for editing, i see the following:
|
Sounds like you are running into a known issue with the Drag & Drop Editor option. Even when you use a Code Module you will still have this issue. For now if you want to get around this you will have to use the Code Editor. Sorry for the trouble this causes. |
Hi, I also encounter this error and only want to use sendgrid templates with the design editor. |
Unfortunately, there is no ETA as this fix is going to take a decent amount of work. All I can say is that this is something that is being worked on currently. |
I think this alternative should be clearly documented here handlebars-documentation, so people can clearly see. It's a bit hard to find this workaround. |
@kylearoberts the whole idea of design templates is so that the marketing team can create beautiful e-mails and the dev team just has to insert the handlebars. After going through the pain of substitutions not working anymore (sendgrid/sendgrid-csharp#716), I am now encountering this. I really need an ETA on this, your next sprint probably starts next week so please plan it, we need this ASAP, this is one of your core features, how come this is not your top priority on the list? It's a frustrating Sunday like this, thanks to SendNothingGrid! |
I am also facing the same issue and I am really not able to figure out whats the error. Everything on code is pretty fine. HTML renders the page if saved via .html . SendGrid seems to gives this error without mentioning the exact error. I dont have if clause. It's a basic template. Any solution to this? |
I'm having the same problem here. The Drag and Drop Editor is not working with double curly brackets. It just simply can't save the template. But, if I remove these double curly brackets from the template, it will save. @apigirl please stop closing the issue since it's not even solved yet. Frustrating! |
What workarounds are you guys using until @apigirl has re-opened and asked their team to fix this? I Experienced the same as daniyaalhadzami, didn't use it that much but was able to get it sometimes to save. IF it saves and the brackets are still there then it will also work. Still waiting on an ETA. I will just shoot in a support ticket as well, who follows? |
Sometimes if the template is not being saved, copy the code and open it up in Brackets editor ( Google it if you don't knw abt this) and then paste it over there... reformat the structure by indentation and copy and paste it back into the Sendgrid edit box. It works sometimes like that. |
I had the support ticket. It was unhelpful. |
Same, supports provides no solution or ETA. I hope via the development community we can push is further ahead because obviously this is really annoying, sendgrid seems te have a culture of ignoring issues until they hope to be disappeared. Perhaps I should start looking for alternatives... |
Any updates on this? |
Trying to keep this thread alive before @apigirl closes it again. |
I've recommended that we use SendGrid at the past few startups I've been at, but this issue tipped me over the edge: unfortunately, I will no longer be recommending SendGrid. Ever since Twilio acquired them, it's gone downhill fast. |
Has any progress been made on this? At the moment, we're creating and having to manage extra templates just to workaround not being able to conditionally remove elements from an email template - very poor DX! |
I just had what I think was the same problem as discussed above with the drag and drop editor. But when I took the underscore out of the merge tag it worked; i.e. {{{subs_date}}} didn't worked but {{{subsdate}}} did. I hope that helps. |
Over a year and this still isn't fixed? That's poor. Thanks @Pete214 unfortunately removing the underscore did not work for me. |
@apigirl @kylearoberts FYI this is a legitimate bug, and not only that, it is a regression. I had a template that was working fine previously with conditionals in it in the scenario that Anyway, I got around the issue by applying the conditional to the ENTIRE table element, with the only difference being the In short, there is an issue with the conditionals being applied to children of table elements. |
We are also facing this problem, despite the clearly documented supported #if statement. Our variables are camelcase so it's not caused by underscores. Edit: The only way to know that there is a problem is to open the developer tools and check the network tab. There we can see that the patch request fails with "The template you provided is invalid." as the response. This is indeed terrible UX. At present we are completely unable to create conditional emails, which is a massive dealbreaker. There is no way we are going to create a new template for each condition. Edit again: |
I ran into the same issue as described on this thread, but I was able to get it to work through some tinkering. Here's my test data: Here's my Text Module content: Test. {{@root.someLink}} And if it's helpful, here's the Text Module code: Viewing that in the Preview panel shows it working how I expected. It also works when I send an email. While messing around I kept saving and sometimes SendGrid said the template saved correctly, but it failed to send the test email even when it said successfully sent. It only sent the email once I got everything exactly right. When I did get the notification that my handlebars code was invalid it didn't tell me why which is super unhelpful. I'm just getting into using SendGrid, but so far my experience hasn't been too positive. Getting everything set up to use their API was straightforward, but the support I'm seeing on this thread is lackluster and UI issues (like the unhelpful "invalid" message and not being able to copy/paste in a Text Module) detract from the overall quality of this service. I hope this helps. Edit: typos |
Seems like some text formatting issues are causing the problem. When I copied the text block to my macbook's notepad app and pasted it back again with cmd + shift + v (pasting without preserving formatting), it works. |
Hi there!
I'm writing a transactional email (with of Sendgrid of course) and I'm having troubles with the if statement support by the Handlebars.
According to the docs of Sendgrid:
https://sendgrid.com/docs/ui/sending-email/using-handlebars/#substitution
And also the docs of Handlebars
https://handlebarsjs.com/
It says that the if statement works like this:
But when I implement this syntaxis in my transactional email it says that is "The template you provided is invalid.", I don't really know why, and the docs doesn't say nothing more, maybe is a bug or a compability issue, that's why I open this issue for its consideration.
The text was updated successfully, but these errors were encountered: