Output:
ejs
HTML:
<a href="http://some-url.com">
test title
</a>
<a href="https://worldbrain.io">
Memex
</a>
<a href="https://weird.io">
Weird title with "quotes"
</a>
Markdown:
[test title](http://some-url.com)
[Memex](https://worldbrain.io)
[Weird title with "quotes"](https://weird.io)
JSON:
{
title: "test title",
url: "http://some-url.com"
}
{
title: "Memex",
url: "https://worldbrain.io"
}
{
title: "Weird title with "quotes"",
url: "https://weird.io"
}
Bonus:
FROM COMPILED STRING
handlebars
HTML:
<a href="http://some-url.com">
test title
</a>
<a href="https://worldbrain.io">
Memex
</a>
<a href="https://weird.io">
Weird title with "quotes"
</a>
Markdown:
[test title](http://some-url.com)
[Memex](https://worldbrain.io)
[Weird title with "quotes"](https://weird.io)
JSON:
{
title: "test title",
url: "http://some-url.com"
}
{
title: "Memex",
url: "https://worldbrain.io"
}
{
title: "Weird title with "quotes"",
url: "https://weird.io"
}
Both ejs
, and handlebars
allow us to handle escaped and unescaped strings.
ejs
exposes full javascript within the templates which might not be ideal (security concerns?)
We could also use "standard" javascript template strings, but then we would have to write the escaping logic by ourselves, and they also (like ejs
) expose full JS runtime.