I am working with Mermaid.js to general a Class Diagram for my hobby project.
I am facing a very basic issue, which I cannot figure out how should I approach it.
Basically, I have the structure generated, but when I push it to the view, it is rendered with double quotes and also the '\n' is showing as well.
Node.js
let unique_Object = _.groupBy(json_result,'ChildRelationship')
let chart_schema = "classDiagram\n"
Object.keys(unique_Object).forEach(function (item){
chart_schema = chart_schema + objectName + " <|-- " + item + "\n"
})
return chart_schema
Koa Route
.get('getD', '/getD', async (ctx) => {
try {
const result = await util.get_childRelationship()
return ctx.render('test',{
object: result
})
} catch (error) {
console.error(error)
}
})
View
<div class="mermaid" id="mermaid">
<%- chart %>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/mermaid/8.4.4/mermaid.min.js"></script>
<script> mermaid.mermaidAPI.initialize({
startOnLoad: true
});</script>
View Result
"classDiagram\nParent <|-- Joe\n"
The browser is ignoring the \n.
If anyone has any idea?