I
I
InfoLabs2017-05-17 14:19:46
Node.js
InfoLabs, 2017-05-17 14:19:46

How to add spaces?

The problem is actually .... The task is to assemble the page from blocks, which means you need to use dynamic include. But out of the box, the pug won't let you do that. Therefore, I use the custom includeBlock function.
index.pug:

body
  h2 Test
  each item, name in blocksList
    != includeBlock('blocks/' + item.path)

index.html:
<body>
  <h2>Test</h2>
Content included blocks
</body>

Actually, why is the tag hierarchy broken in the final file? How can this be fixed?
pug({
        pretty: true,
        pug: pug.default,
        data: { 
            blocksList: list,
            includeBlock: function (_path, params) {
                return pug.default.renderFile(path.default.dir.pug + '/' + _path, {
                    pretty: true,
                    locals: params || {}
                });
            }
        }
    });

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question