0

Is there any good way to build Dart app with Web-UI and dynamically loading over network new HTML templates (client side templating)?

It looks like Web UI templates are always load together with generated *.js files:

  <head>
    <!-- this will be transformed by WebUI compiler to *_generated.js code -->
    <link rel="components" href="common_templates.html"> 
  </head>
4

3 に答える 3

0

I am working toward a single page application that dynamically loads new content into the content section of the page based on the menu selected on the left. The content section gets populated from a WebUi component, but it does happen dynamically, and it does happen client side. On the menu, I have something like;

        <li> <a href="#/active">Active</a> </li>
        <li> <a href="#/completed">Completed</a> </li>

where i have the application respond to the hash changing when a menu item is clicked. They do something similar in the WebUi implementation of the ToDo app.

The content has a conditional template that loads a WebUi component based on the menu selected.

This may not be what you had in mind. Please provide more details if I am off track here.

于 2013-02-28T02:50:45.103 に答える
0

Currently it's not possible to dynamically load and process templates with WebUI. WebUI needs to process the templates ahead of time. I think @ChrisBuckett suggestion from the other answer/comments would be a great way to go: use deferred loading when it becomes available.

Another crazy idea would be to ship the web-ui compiler with your app and process the templates in the browser. Note, this is not even possible today because web-ui currently cannot be compiled with dart2js (it has some dependencies on dart:io). Hypothetically, if it were possible, it's likely going to be a lot bigger than shipping the extra templates. So, if your goal was to reduce the initial download, then this idea is a no-go.

于 2013-02-28T23:03:11.773 に答える
0

It is now possible to performed delayed loading of Dart code. If your client side templates are implemented as Dart source, you can use the DeferredLibrary class.

A more detailed article will likely show up soon in the articles section of Dart website.

于 2013-03-19T21:56:05.923 に答える