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 DeclarationBase have 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 Emit instructs SuperScript to pull the specified instance of DeclarationBase, determine which emitter should process it, and the passes the instance to that emitter.

  • Output all declarations for a specific emitter

    By specifying the Key of 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 EmitFor instructs SuperScript to retrieve all instances of DeclarationBase which reference the specified emitter Key, then pass this collection of DeclarationBase objects to that emitter.

  • Output for all emitters

    By calling EmitForAll the output of all configured emitters can be written in the same location.

                                    <%: SuperScript.Declarations.EmitForAll() %>
                                
                                    @SuperScript.Declarations.EmitForAll()
                                

    Calling EmitForAll instructs SuperScript to group all instances of DeclarationBase by their Key properties, then pass each group to that group's emitter.

What Next?

Read about emitter bundles here.

Read about declarations here.