nue icon indicating copy to clipboard operation
nue copied to clipboard

component at layout.html compile error

Open Hi-Alan opened this issue 10 months ago • 3 comments

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>

Hi-Alan avatar Apr 05 '24 03:04 Hi-Alan

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

nobkd avatar Apr 07 '24 00:04 nobkd

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>

Hi-Alan avatar Apr 07 '24 07:04 Hi-Alan

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

nobkd avatar Apr 14 '24 23:04 nobkd

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.

nobkd avatar Oct 06 '24 17:10 nobkd