Giter Site home page Giter Site logo

Comments (7)

GemN avatar GemN commented on June 2, 2024 1

Hello,
Got exactly the same problems when rendering emails to send to different customers in AWS lambda

from heml.

GemN avatar GemN commented on June 2, 2024 1

I found a workaround.
I actually build with a script all my folder heml, into a folder html. Push both folders and in the code I directly load from the html folder (and for variables i use Mustache)

Script to build:

#!/bin/bash
type heml >/dev/null 2>&1 || { echo >&2 "Require heml. Please install (yarn global add heml)."; exit 1; }

for entry in "heml"/*
do
  if [ -f "$entry" ];then
    echo "-- Building $entry to html"
    filename=${entry##*/}
    heml build $entry --output html/${filename%.*}.html
  fi
done

Load html email:

const htmlEmail = fs.readFileSync(`${__dirname}/../emails/templates/html/myemail.html`, {
  encoding: 'utf-8',
});

Build the emails with dynamic variables:

const htmlEmailWithValues = Mustache.render(htmlEmail, emailData);
const form = new FormData();
form.append('from', 'App <[email protected]>');
form.append('to', `${firstname} <${email}>`);
form.append('subject', subject);
form.append('html', htmlEmailWithValues);

from heml.

robmcfeely avatar robmcfeely commented on June 2, 2024

@BenMansley @GemN or anyone find a solution to this? Same problem. It pretty much renders this project useless for service type activity :(

from heml.

Devessier avatar Devessier commented on June 2, 2024

I'm getting the same error.
Has anybody found a solution or a workaround 😄 ? @BenMansley @GemN @robmcfeely

from heml.

robmcfeely avatar robmcfeely commented on June 2, 2024

from heml.

Devessier avatar Devessier commented on June 2, 2024

@robmcfeely Okay, thank your for your reply ! 👍

from heml.

Devessier avatar Devessier commented on June 2, 2024

@GemN Great workaround !

I think I would have used your solution if I wouldn't must dynamically generate content using loops or conditions.
I created a small class that spawns 4 Node.js thread workers, each of them executing the heml function while waiting for the previous execution to be completed in order to prevent race conditions we encountered.
Like that I don't need to rely on HEML CLI.

The Gist containing the code : https://gist.github.com/Devessier/f17c3bf4e7f9a799059d1fec110ba841

from heml.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.