Considerations for Compiling and Rendering the Asset Model

Compile an asset in the context of a channel to return a flattened string of the asset content. You can use two compiling types:

  • standard compiling
  • rendering

Rendering accounts for superContent and design. Use rendering only for user representation and manipulation of content, as opposed to sending and publishing content.

  • IF an asset contains content:

    • FOR EACH placeholder block or slot in the content:

      • REPLACE the placeholder with the compiled string from the block or slot
    • RETURN replaced content

  • ELSE:

    • IF an asset contains views:

      • IF an asset contains a view for the specified channel:

        • RETURN the compiled channel view
      • ELSE IF an asset contains an HTML view:

        • RETURN the compiled HTML view
      • ELSE:

        • RETURN empty string
  • IF an asset contains content, design, or superContent:

    • IF an asset contains superContent and superContent is not empty:

      • usedContent = superContent
    • ELSE IF an asset contains content and content is not empty:

      • usedContent = content
    • ELSE IF an asset contains design and design is not empty:

      • usedContent = design
    • ELSE:

      • RETURN empty string
    • FOR EACH placeholder block or slot in the content:

      • REPLACE the placeholder with the rendered string from the block or slot
    • RETURN replaced content

  • ELSE:

    • IF an asset contains views:

      • IF an asset contains a view for the specified channel:

        • RETURN the rendered channel view
      • ELSE IF there is an HTML view:

        • RETURN the rendered HTML view
      • ELSE:

        • RETURN empty string

This JavaScript code example creates a full compiler.