Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
sendgrid-templated
Advanced tools
Sendgrid extension for easy use with html templates and data injection.
sendgrid-templated
extends @sendgrid/client
and @sendgrid/helpers
to allow for easy use with html templates and data injection.
Use npm i sendgrid-templated
to install the package via NPM.
import Email from "sendgrid-templated";
const email = new Email({
apiKey: "SENDGRID_API_KEY",
from: { email: "foo@bar.xyz", name: "Jane Doe" },
to: { email: "fizz@buzz.io", name: "John Doe" },
subject: "Welcome",
template: {
filePath: path.join(__dirname, "templates/welcome.html"),
data: { firstName: "John", message: "Thanks for joining!" }
}
});
email
.send()
.then(() => {
// Success!
})
.catch(err => {
// Handle err
});
Assuming templates/welcome.html
looks something like:
<div>
<h1>Welcome, {{firstName}}!</h1>
<div>{{message}}</div>
</div>
The config object supplied to the contructor has the following options:
apiKey
: The API key you receive from sendgrid. Defaults to process.env.SENDGRID_API_KEY
from
: Object containing the email
and [optional] name
for the email's from
info. Defaults to process.env.SENDGRID_FROM_EMAIL
and process.env.SENDGRID_FROM_NAME
to
: Object containing the email
and [optional] name
for the email's to
info.subject
: The subject of the email.template
: [optional] Object containing info about the template to be used. See Template Config Options
below for more details.The template config object has the following options:
filePath
: The path to the html file to be used as the email template.data
: [optional] Object containing key/value pairs of injections to be made into the template.wrappers
: [optional] A tuple of opening and closing char(s) to denote a template variable. (e.g. ["%", "%"]
would denote a template var of format %firstName%
)Contributions are welcome!
To continue development on sendgrid-templated
, clone this repo, then run npm i
to install all necessary dependencies.
You can run npm build
to build the project, and npm test
to run tests.
FAQs
Sendgrid extension for easy use with html templates and data injection.
The npm package sendgrid-templated receives a total of 1 weekly downloads. As such, sendgrid-templated popularity was classified as not popular.
We found that sendgrid-templated demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.