UIZE JavaScript Framework

TO DO - Uize.Generator

This is a proposal document for a Uize.Generator module.

1. - from the widget's perspective as a user of generators

you have a set of display properties (state properties that are reflected in the UI)

1.1. - a widget class should be able to declare which of its state properties affect display

1.1.1. - of the state properties that affect display...

which are updated by the client code
which are handled as inputs by the generator specified by the html state property
some display state properties may be handled by both the generator and client code
if (property values are modified) {
  displayPropertiesModified = /* code to determine this */
  if (displayPropertiesModified.length) {
    displayPropertiesOnlyReflectedByRenderWereModified = /* code to determine this */
    if (displayPropertiesOnlyReflectedByRenderWereModified && can re-render DOME) {
      unwireUi ();
      remove DOM
      re-render DOM and insert
      wireUi ();
      remove properties handled by re-render from displayPropertiesModified
    }
    if (displayPropertiesModified.length) {
  }
}

1.2. - html state property

string, being a template into which a limited set of params are substituted
a function, which can generate the HTML, and which receives no parameters but which is called as a method on the instance (so can access property values)
an instance of a generator class

2. - generator principles

a generator should be able to leverage or depend on other code modules, so it should be declared with a module declaration
a generator should be able to declare its inputs
a generator should not assume the context of its usage, so it should be able to operate on the server side or in a non HTML document context

3. Uize.Generator implements simply...

3.1. - state properties

asynchronous
params

3.2. - getOutput (params,callback)

result can be a string, or an object of which text is a property

4. - good tests of the paradigm would be...

implementing the slider skin extension, in such a way, that setting properties track, knob, and other colors would trigger a re-render
providing the functionality of Zazzle.ControlPoptions in Uize.Widget.Options

5. - classes of generator

5.1. - thoughts

generators should be able to require any module in order to accomplish generating their output
generators should be able to use JavaScript templates, or other means
generators should be able to be used in a context outside of the Web, Web pages, and browsers
widgets should be able to use generators to generate their markup
the same class of widget should be able to use any number of generators, and theoretically, different widget classes should be able to use the same generator
a generator should be able to leverage other generators in the process of generating their output
generators should be able to declare their input interface

5.2. Uize.Generator (base class)

params

5.3. Uize.Generator.Basic (utilizing basic substitution)

params
templateStr

EXAMPLE

Uize.Generator.Basic ({
  params:['property1','property2'],
  templateStr:'This template supports [#property1] and [#property2]'
});

5.4. Uize.Generator.Tokenized

params
templateStr
tokenNaming

EXAMPLE

Uize.Generator.Tokenized ({
  params:['property1','property2'],
  templateStr:'This template supports {property1} and {property2}',
  tokenNaming:'{KEY}'
})

5.5. Uize.Generator.Population

params
templateStr
templateItem

EXAMPLE

Uize.Generator.Population ({
  params:['property1','property2'],
  templateStr:'This template supports property1Value and property2Value',
  templateItem:{
    property1:'property1Value',
    property2:'property2Value'
  }
})

5.6. Uize.Generator.Function

generator

EXAMPLE

Uize.Generator.Function ({
  params:['property1','property2'],
  generator:
    function (_params) {
      return 'This template supports ' + _params.property1 + ' and ' + _params.property2;
    }
});

5.7. Uize.Generator.Ajax

serviceUrl

EXAMPLE

Uize.Generator.Ajax ({
  params:['property1','property2'],
  url:'service/getcomponent?'
});

NOTES

provides a system for expressing dynamically loaded HTML through service
should it require its own instance of Uize.Comm.Ajax
no, because it should be able to use whatever the protocol is that's in use?
should defer to page's environment for URLs and comm

5.8. Uize.Generator.Async

5.8.1. requires a...

comm object
environment for URLs

5.8.1.1. - or...

maybe it just requires a loader...

to provide the maximum flexibility, the only thing that an async generator needs is a loader

Uize.Generator.Http