Created
April 15, 2019 21:56
-
-
Save jgwill/7e32a94c66b4a541958ab834377554ab to your computer and use it in GitHub Desktop.
@stcgoal That we can use Markdown into Templates data that will be rendered as HTML
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//import | |
var h = require('handlebars'); | |
//@stcgoal That we can use Markdown into Templates data that will be rendered as HTML | |
h.registerHelper('markdown', require('helper-markdown')); | |
//------------------------------------------- | |
//@STCGoal Use Markdown in your Code to Render it as HTML | |
//Handlebars sources | |
var code = ` | |
<div> | |
<h1>{{title}}</h1> | |
<p>{{description}}</p> | |
<hr>Using Markdown handlebars-helper<hr> | |
{{#markdown}} | |
# Title Something | |
--- | |
* Points a | |
* Point b | |
{{/markdown}} | |
</div> | |
`; | |
//Data structure with values | |
var data = { | |
title : "Hello world Markdown", | |
description: "Hello world is a common Magna cillum consequat incididunt laboris nisi voluptate fugiat id voluptate incididunt.", | |
peoples:[{name:"Guillaume",note:"main scientist and artist"},{name:"Peter Pan",note:"ficticious caracter"}] | |
}; | |
var template = h.compile(code); | |
console.log(template(data)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment