Skip to content

Instantly share code, notes, and snippets.

@daliborgogic
Last active September 28, 2018 20:02
Show Gist options
  • Save daliborgogic/bc3c50801821d6a825269e5e9e7cd470 to your computer and use it in GitHub Desktop.
Save daliborgogic/bc3c50801821d6a825269e5e9e7cd470 to your computer and use it in GitHub Desktop.
const separator = (height = 12, color = '#e0e0e0') =>
`<tr><td height="${height}"></td></tr>
<tr><td height="${height}" style="border-top: 1px solid ${color};"></td></tr>`
const space = x => `<tr><td height="${x}"></td></tr>`
const label = x => `<tr><td style="font-size: 12px; color: #999;">${x}</td></tr>`
const input = x => `<tr><td style="font-size: 16px;">${x}</td></tr>`
const check = (a, b) => { return a ? label(b) + input(a) + separator() : '' }
const footer = `<tr>
<td style="font-size: 12px; color: #999999;">
<b>NAME</b><br>
Short description<br>
Street<br>
City, Address
</td>
</tr>`
const body = data => {
const {
title,
office,
department,
firstName,
lastName,
email,
phone,
resumeWrite,
letterWrite,
linkedin,
website,
question
} = data
return `<table class="table" width="400" border="0" cellpadding="0" cellspacing="0" align="center">
${label('Position')}
<tr><td style="font-size: 32px; font-weight: bold;">${title}</td></tr>` +
space(64) +
label('Office') +
input(office) +
separator() +
label('Department') +
input(department) +
separator() +
label('First Name') +
input(firstName) +
separator() +
label('Last Name') +
input(lastName) +
separator() +
label('Email') +
input(email) +
separator() +
check(phone, 'Phone') +
check(resumeWrite, 'Resume/CV') +
check(letterWrite, 'Cover Letter') +
check(linkedin, 'Linkedin Profile') +
check(website, 'Website') +
check(question, 'Question') +
space(64) +
footer +
space(64) +
`</table>`
}
module.exports = async data => {
return `<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>${data.title}</title>
<style></style>
</head>
<body>${body(data)}</body>
</html>`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment