SuperScript
This documentation is still being written. Please bear with us while we complete this documentation.
Emitting Declarations
We now know that an application using SuperScript has an application-wide collection of declarations, and that these are then passed to emitters which process and modify the declarations before writing a desired output to the webpage.
One thing which has yet to be explained is how and which emitter the declarations are passed through.
How to Emit
In the desired, optimal location for writing the output of an emitter, there are three possible methods for writing the output.
-
Output a specific declaration
By specifying the Name property of a declaration. [Important: not all implementations of
DeclarationBasehave a Name property.][WebForms] <%: SuperScript.Declarations.Emit("myVar") %>[Razor view] @SuperScript.Declarations.Emit("myVar")The above examples assume that a declaration with the Name "myVar" has been added to
Superscript.Declarations.Calling
Emitinstructs SuperScript to pull the specified instance ofDeclarationBase, determine which emitter should process it, and the passes the instance to that emitter. -
Output all declarations for a specific emitter
By specifying the
Keyof an emitter.[WebForms] <%: SuperScript.Declarations.EmitFor("javascript") %>[Razor view] @SuperScript.Declarations.EmitFor("javascript")The above examples assume that an emitter has been declared with the
Key"javascript".Calling
EmitForinstructs SuperScript to retrieve all instances ofDeclarationBasewhich reference the specified emitterKey, then pass this collection ofDeclarationBaseobjects to that emitter. -
Output for all emitters
By calling
EmitForAllthe output of all configured emitters can be written in the same location.<%: SuperScript.Declarations.EmitForAll() %>@SuperScript.Declarations.EmitForAll()Calling
EmitForAllinstructs SuperScript to group all instances ofDeclarationBaseby theirKeyproperties, then pass each group to that group's emitter.
What Next?
Read about emitter bundles here.
Read about declarations here.