v0.6.22

Block Insertion

Last updated


This page covers loading an external HTML file into the template with <temp :path>.

Syntax


  1. <div id="app">
  2. <temp :path="/components/header.html"></temp>
  3. <temp :path="footerUrl"></temp>
  4. </div>
  5. <script>
  6. const app = new QUI({
  7. id: "app",
  8. data: { title: "QuickUI", footerUrl: "/components/footer.html" },
  9. });
  10. </script>
Live preview · @pardnchiu/quickui@0.6.22

The content of header.html replaces the <temp> element itself; inserted content can use {{ }}, :for, :if and every other directive.

Rules


RuleDescription
Tag:path only works on <temp>
PathLooked up as a data key first, otherwise used as the URL
When it loadsFetched again on every render; caching is left to the browser HTTP cache
OrderLoaded after :for and :if, then :for and :if run again on the inserted content
EnvironmentRequires an HTTP server; fetch fails under file://

Failure Cases


CaseResult
A 404 or other error statusThe status is not checked, so the error page's body is inserted
Network error or CORS rejectionfetch throws, that render stops, and the page keeps the previous result

Before deploying, make sure every :path points to a file that exists.
中文