Comments (3)
I’m not sure I’ve understood this issue. You can already add both merge variables (global ones though, not per recipient) and template content data. What exact change are you expecting for this issue?
BTW, thanks for the kind words.
from mandrill.
Thanks for the quick reply.
I have a template in Mandrill with the following merge var and dynamic section.
Hello *|NAME|* also known as <span mc:edit="NAME"></span>
Example in README
tmplName := "hello-world"
email := "[email protected]"
name := "mostafah"
data := map[string]string{("NAME": name})
mandrill.NewMessageTo(email, name).SendTemplate(tmplName, data, true)
This will send and email with the content
Hello also known as mostafah
If you add the AddGlobalMergeVars, it will format the data for Merge Vars as well
// Same variable declaration as above but do the following
msg := mandrill.NewMessageTo(email, name)
msg.AddGlobalMergeVars(data)
result, err := msg.SendTemplate(tmplName, data, true)
Now the email will be
Hello mostafah also known as mostafah
I believe the issue is that SendTemplate just sends template data...
data.TemplateName = tmpl
data.TemplateConent = mapToVars(content)
While AddGlobalMegeVars adds the data to the the msg
msg.GlobalMergeVars = append(msg.GlobalMergeVars, mapToVars(data)...)
Thanks.
from mandrill.
Well, that’s by design. Mandrill accepts two kinds of data: merge variables and template data. You can send both with this package, but they are separate things. I can’t send what is passed for template data as merge variables too. That takes the ability to set different merge variables from people.
Mandrill’s API provides two different arrays for these, and the library does that too.
To tell it again in other words, Mandrill’s Send-Template function takes these (and other things) as JSON input:
{
"template_name": "foo",
"template_content": [
{"name": "varname", "content": "value"},
{"name": "varname", "content": "value"},
…
],
"message": {
"global_merge_vars": [
{"name": "varname", "content": "value"},
{"name": "varname", "content": "value"},
…
],
}
}
You can set the first one with function SendTemplate
and the second one with function AddGlobalMergeVars
. Merging the two doesn’t make sense for other users.
from mandrill.
Related Issues (5)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mandrill.