Giter VIP home page Giter VIP logo

Comments (4)

granicz avatar granicz commented on July 23, 2024 1

There would be near-zero chance for an HTML file to be used with multiple instantiations, so I'd just go with 1).

from core.

Jand42 avatar Jand42 commented on July 23, 2024

@granicz I was thinking we can bring Sitelets/SPAs/Offline sitelets all together.
But Offline/SPA would have no dynamic content, it could only load data from server by RPCs to initialize itself. The point to use predefined html (compile-time generated for Offline and hand-written for SPA) is to not touch it when serving.
So this piece makes no sense: we can't serve a static file AND dynamic content at the same time - which one is it: Content.PageFromFile("home.html", Client.HomePage())

from core.

granicz avatar granicz commented on July 23, 2024

The point of Content.PageFromFile is to enable serving a potentially non-templated SPA from a sitelet. (Even for templated cases such as the one above, the server can compute the response much faster because it doesn't need to use UI templates for it.) As such, it involves an element of dynamism: while the response is based on a static HTML file, it's actually augmented with a script block that takes care of the after-load initialization, supplied by the second, quoted argument.

In a way, this is similar to serving a page with an OnAfterRender (OAR) function, without the need to add an OAR or even using UI templating.

The intended behavior is that each Content.PageFromFile establishes a unique bundle and the server references it at runtime when generating the response from the HTML file (first argument).

from core.

Jand42 avatar Jand42 commented on July 23, 2024

@granicz I see, what should the bundle .js be named? From your use case, it seems you don't want to pre-bake the initialization into "home.html", and this would be looked up from app root, not web root (not a public file by itself).

So if you want to use the same html in multiple places, we could do this:

  1. by default put code for functions and argument deserializers used in all "home.html" initializations by Content.PageFromFile into a single home.js bundle
  2. also have an optional argument for bundle name, that would specify the .js name that could be different, and then you have smaller bundles when you reuse same html with different content

from core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.