npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vs-email-template

v1.0.3

Published

To be able to use email templates, you must render HTML String. That won't be a problem if it's just a short template. But what if it's a long email template with lots of variables in it? The code will not be clear because it is both a string and has to b

Downloads

1

Readme

Description

To be able to use email templates, you must render HTML String. That won't be a problem if it's just a short template. But what if it's a long email template with lots of variables in it? The code will not be clear because it is both a string and has to be assigned a variable inside

From

<div style="margin-bottom: 20px">
    <div><p style="font-weight: bold">This is Title Mail</p></div>
</div>
<div style="margin-bottom: 20px">
    <p>Sort Content</p>
</div>
<div>
    <div>
        <p><b>Name</b></p> : T
    </div>
    <div>
        <p><b>Age</b></p> : 18
    </div>
    <div>
        <p><b>City</b></p> : Tokyo
    </div>
    </div>
</div>

To

import Template from 'vs-email-template';
function renderTemplate(){
    return Template()
        .title('This is Title Mail', { 'margin-bottom': '20px' })
        .text('Sort Content', { 'margin-bottom': '20px' })
        .list({
            "Name": "T",
            "Age" : "19",
            "City" : "Tokyo"
        })
        .render()
}

Installing

Package manager

Using npm:

npm install vs-email-template

Using yarn:

yarn add vs-email-template

Usage

Example

import Template from 'vs-email-template';

function renderTemplate(){
    return Template()
        .title('Title Hello', { 'margin-bottom': '20px' })
        .text('Hello')
        .render()
}

We can use these are API to choose type of render

| API | Return | |----------------------------------------------------------------|-----------| | title(content: string, style?) | class | | text(content: string, style?) | class | | custom(content: string) | class | | list(data: {[key : string] : string}, styleContainer?, style?) | class | | getDefaultStyle() | JSON | | setDefaultStyle(style) | void | | render() | HTML Code |

Then we need use function render() to render a string HTML and we can use that in email template

With multiple paragraph

import Template from 'vs-email-template';

function renderTemplate(){
    return Template()
        .title('Title Hello')
        .text('Hello', { 'margin-bottom': '20px' })
        .text('My name is T')
        .list({
            "Age" : "19",
            "City" : "Tokyo"
        })
        .render()
}

With custom tag if you need to add some tag

import Template from 'vs-email-template';

function renderTemplate(){
    const customIntro = Template().tag('div').tag('p',{color: "red"}).content('hello this is intro')
    return Template()
        .title('Title Hello')
        .custom(intro)
        .text('I'm here)
        .render()
}