I have a Quasar SSR app that I need to dynamically inject HTML content around the <div id="q-app">
element (ie. custom header and footer content) as the page is rendered on the server. The HTML content in question will be pulled from other snippet files stored on the server.
I have tried adding the content to the ssrContext
from within a boot file and then inserting this in index.template.html using {{ }}
tags, but this results in HTML-escaped output:
In whitelabeltemplate.js (boot file):
export default ({ app, ssrContext }) => {
ssrContext.templateHeaderHTML = '<div>This is the header</div>'
}
In index.template.html:
<body>
<% if (htmlWebpackPlugin.options.ctx.mode.ssr) { %>{{ templateHeaderHTML }}<% } %>
<!-- DO NOT touch the following DIV -->
<div id="q-app"></div>
</body>
Results in:
<body class="desktop no-touch body--light" >
<div>This is the header</div>
<!-- DO NOT touch the following DIV -->
<div id="q-app" ...
...
</body>
Is there an alternate method of injecting this content to avoid the escaping?