Skip to content

Commit

Permalink
fix: render template from string instead
Browse files Browse the repository at this point in the history
  • Loading branch information
joni3k committed Aug 18, 2022
1 parent b457cf6 commit 77c4df7
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
21 changes: 0 additions & 21 deletions src/smartstack/description/description.njk

This file was deleted.

26 changes: 23 additions & 3 deletions src/smartstack/description/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
import * as path from 'path';
import { loadTemplate, renderTemplate, TemplateContext } from '../../template';
const template = loadTemplate(path.join(__dirname, 'description.njk'));
import { renderTemplate, TemplateContext } from '../../template';

const template = `{#
Template for Stack Description prop
--------------------------------------------------------------------------------
AWS CloudFormation stack descriptions have a maximum length of 1024 bytes.
But since we're opinionated, a stack summary should fit into a tweet.
#}{#
#}{% if environment | notEmpty %}{#
"Staging Environment: "
#}{{ environment | pascal | stripUnderscore | truncate(32, true, "") | append(" Environment: ") }}{#
#}{% elif account | notEmpty %}{#
"Dev Account: "
#}{{ account | pascal | truncate(32, true, "") | append(" Account: ") }}{#
#}{% endif %}{#
"My description goes here"
If truncated, an ellipsis is appended:
https://mozilla.github.io/nunjucks/templating.html#truncate
#}{{ body | truncate(280, true)}}`;

interface TemplateProps extends TemplateContext {
body: string;
Expand Down

0 comments on commit 77c4df7

Please sign in to comment.