leemunroe / grunt-email-workflow

A Grunt workflow for designing and testing responsive HTML email templates with SCSS.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: Dynamic values to layout

yhabib opened this issue Β· comments

Thanks for this awesome project πŸ™Œ πŸ™Œ πŸ™Œ πŸ™Œ

I was wondering if it is possible to somehow pass a dynamic value for the subject when calling a layout from an email:

---
layout: default.hbs
subject: Branded transaction email example
---
commented

@yhabib - Glad you're enjoying it!

Technically, the subject in the email is outside of the templates - that would be up to whatever scripts or ESP you use.

w/in this tool, the "subject" front-matter value is what sets the <title> element used in your layout(s). Below example passes the liquid or hbs variable liquidDynamicSubjectVariableName through and could be rendered at time of send.

---
layout: default.hbs
subject: "{{ liquidDynamicSubjectVariableName }}"
---

Does that answer your question?

@taeo thanks for your quick response.

Not exactly. What I would like to do is to be able to inject the value of subject from one of my json files in data.

My use case is as follows. I need to bring a new language to the templates, so I'm moving all the content to a json file within data and there I'm creating as many json files as languages I need to support.
For the body of the email I can just use {{{ translations_en.title }}} but couldn't figure it out how to do that for the title.

But from your answers I guess this is not possible right??

Thanks again for the support.

commented

@yhabib - Sorry, I still don't understand your use case / what you're doing.

That said, I believe this syntax will work for you

---
layout: default.hbs
subject: <%= translations_en.title %>
---

Thanks @taeo this helps me a lot πŸ™Œ !

I want to reuse the templates in different languages, and therefore need to inject all the content from a .json file before building the html. Basically multi-language support.

Thanks again.