'CodeMirror: load default yaml file

I'm currently trying to get CodeMirror to load a yaml file for me.

Backend (slimmed down for stackoverflow):

    import fs from "fs-extra";
    import yaml from "js-yaml";

    const conf = yaml.load(fs.readFileSync('./config.yml', 'utf-8'));
        
    router.get('/', (req, res) => {
        res.render('settings.ejs', {
            page_name: 'settings',
            yaml_config: JSON.stringify(conf)
        });
    
        console.log(JSON.stringify(conf));
    });

Frontend:

    <div id="editor"></div>
    <script>
        const editor = CodeMirror(document.getElementById('editor'), {
            mode: 'yaml',
            styleActiveLine: true,
            lineNumbers: true,
            foldGutter: true,
            gutters: [
                "CodeMirror-linenumbers", "CodeMirror-foldgutter"
            ],
            theme: 'material',
            value: "<%= yaml_config%>"
        });
    </script>

Without the JSON.stringify will just load "[Object] [object], the console output of console.log(JSON.stringify(conf)); is: {"port":"3000","maxCPU":"30","maxMem":"4","maxDisk":"2"}, but whats being written to CodeMirror is {&#34;port&#34;:&#34;3000&#34;,&#34;maxCPU&#34;:&#34;30&#34;,&#34;maxMem&#34;:&#34;4&#34;,&#34;maxDisk&#34;:&#34;2&#34;}

config.yml;

---
port: '3000'
maxCPU: '30' # in %
maxMem: '4' # in GB
maxDisk: '2' # in GB

Any solutions to my problem?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source