nue
nue copied to clipboard
component at layout.html compile error
I defined a component at site-level layout.html
, it runs ok if there is no<script>
block;
An error raised parse error layout.html
for codes:
<section @name="compile-time-component">
It will be compiled to static html:{title}{title1}
<script>
title1 = `New title`
</script>
</section>
I can't reproduce this. The code runs just fine when I use the <compile-time-component />
.
(I used the Simple Blog
example and pasted your code to the layout.html
and added the component to the <main>
section. I'm using Nue(kit) 0.5.3, Bun 1.1.2, Linux)
Can you create a minimal reproduction/implementation example? (e.g. a gh repo, or a simple layout.html
+ index.md
, or an archive file, or further reproduction steps)
Maybe details about System (Windows, Linux, Mac, ...), Nuekit version, runner (node, bun, ...), package manager (bun, yarn, npm, pnpm, ...) can help too.
Thank you
Thank you for your reply.
If there is One Of <script>
blocks in site-level layout.html, or comment import
line, It runs OK.
MacOS 13.2.1 (22D68) Nue 0.5.3 • Bun 1.0.36
<script>
import { render, parseFile } from 'nuejs-core'
// const [app, ...utils] = await parseFile('./global/app-entry.nue')
// tmpl = `<app-entry title="title for page 3" :description desc="client?? not execution" />`
// html1 = render(tmpl, {
// description: 'how can I define a component that runs at server side at runtime not compile-time?',
// question: 'how can I define a component that it\'s props is a promise? await etc '
// }, utils)
</script>
<footer>
<compile-time-component title="compile time component"></compile-time-component>
</footer>
<section @name="compile-time-component">
It will be compiled to static html:{title}{title1}
<script>
title1 = "New title"
</script>
</section>
I don't think this code should be defined in a layout file. But I also don't know how to do server side components, but here are related discussions / issues:
- #231
- #234
cc @tipiirai maybe you can tell those / this issue if/how this is already implemented, or if this is just missing from the docs? When I read the first discussion, I read it, as if this is already implemented...
Edit: It seems like nue does not support server side (runtime) components, but only layout components that are compiled away on compile/build time
Server-side runtime components aren't supported by nue
. There are only client-side components and compile-time / layout components. I think the naming of server-side components for the latter, makes it a bit unclear.
I don't think, there's any plan for this, but if you really need this, and want to know if it is coming, please open a new issue, as this one is a bit unclear about it.