Closed lukasoppermann closed 4 years ago
Okay, I am getting closer, the issue is actually in the layout
template that is referenced in the article
.
// article.ts
import layout from '../layout'
import convertRichText from '../../../app/services/convertRichText'
const { html } = require('@popeindustries/lit-html-server')
const { unsafeHTML } = require('@popeindustries/lit-html-server/directives/unsafe-html.js')
// define special article styling options
const options = {
bodyClass: 'Page-Type__Article Article',
head: html`
<link type="text/css" href="/css/article.css" rel="stylesheet" />
`
}
// export template
export default (article) => layout(html`
test
`, options);
// layout.ts
import meta from './meta'
const { nothing, html } = require('@popeindustries/lit-html-server')
const { unsafeHTML } = require('@popeindustries/lit-html-server/directives/unsafe-html.js')
// get correct filesnames after appending unique string
const files = require('../../app/services/files')()
// read file to inline directly into template
const indexjs = require('fs').readFileSync('./public/' + files.js['js/index.js'])
export default (content: string, options: { [prop: string]: string; } = {}) => html`
<!DOCTYPE html>
<html lang="en">
<head>
${meta()}
<script>${unsafeHTML(indexjs)}
</script>
<link type="text/css" href="/${files.css['css/app.css']}" rel="stylesheet" />
${typeof options.head !== 'undefined' ? html`${options.head}` : nothing}
</head>
<body class=" temp-body">
<div id="page" class="Grid">
${content || ''}
</div>
</body>
</html>
`
Removing this line ${typeof options.head !== 'undefined' ? html
${options.head}: nothing}
fixed it. So obviously I am doing something wrong here, but I don't get what I am doing wrong.
Can you please advise here?
I am having the same issue when trying to insert variables with:
html`content`
I have to use a function that returns this to make it work.
Hi. Sorry you hit this problem, which is a result of a performance compromise to minimize the number of TemplateResult
instances (returned from calls to html
) created during render. The instances are single use only, so reusing "saved" templates results in an error on the second render.
There obviously should be a more helpful error message, but I'm also unhappy with this compromise, and I'd like to remove this limitation. Hang tight...
Okay, nice. Is #114 going to be the fix?
Yes. Just adding some type-related fixes before publishing
released as version 1.4.0
Thank you for the very quick response.
Hey @popeindustries,
I am getting the following error (I hope it has something to do with the package and you can help).
The code that throws this is:
Which in turn is called by:
The weird part is that it only happens the second time I call the url on the browser. The first time it works fine.
articleVar
both times actually has thestrings
property set.I am probably missing something stupid and would be very happy if you could help me out. Thanks.