Source Code Asset


Source Code Assets are used for entering source code or scripts such as JavaScript or PHP. They are created and edited with a mini Source Editor. Unlike Plain Text Assets, characters are not escaped. Most assets created using the Source Code Asset are not rendered when viewed in the WYSIWYG Editor. There is no preview for how these assets appear once rendered. Source Code Assets support Dependency Manager tags and linking. This type of asset is available across sites within an account unless Lock to Site is selected. By default user levels 4 and higher have access to the Assets section and can create assets. Administrators can further restrict access by assigning an access group to the asset or a readers group to the asset

OU Campus utilizes XML/XSL to render pages. Source Code Assets must therefore maintain valid XML syntax rules to avoid causing errors when placed on pages. 

Note: Boolean attributes are not valid XML. For these attribute types, add the attribute name as the value. E.g., <script async></script> should be written as <script async="async"></script>.

Example of Source Code Asset Configuration

Source Code Asset

Creating a Source Code Asset

  1. Navigate to Content > Assets.
  2. Click the New button.
  3. Select Source Code from the menu. This displays the New Source Code Asset screen with three groupings of content: Asset Info, Access Settings, and Asset Content.
  4. The following items are available for configuring the asset.
    • Name: Define a friendly name that will help users identify it for use within the WYSIWYG.
    • Description: The description can also be helpful to a user when selecting an asset as it is shown in the Asset Browser (in the WYSIWYG Editor, for example) when hovering over the asset name.
    • Tags: Any tags associated with an asset during asset creation can be helpful to a user in selecting an asset, either when using the WYSIWYG Editor or from the list view on the Assets screen, as tags can help delimit the list. 
    • Lock to Site: Select the checkbox to disallow use of the asset outside of the site. By default, assets are available to all sites within an account; if the asset should only be available to the site in which it was created, then select this checkbox.
      Asset Info
    • Access Group: Assigns an access group specific to who can edit the asset. "Everyone," the default, indicates that every user within the account can edit and manage the asset from the Access screen.
    • Readers: Assigns an access group specific to who can use the asset. Everyone, the default, indicates that every user within the account can insert the asset from the WYSIWYG.
      Access Settings Panel
    • Asset Content: The Asset Content field for a Source Code Asset is a mini–Source Editor and includes the following functionality:
      • Undo/redo
      • Find/replace with regex option
      • Go to line
      • Line wrap option
      • Ability to insert a file path by browsing or manually from either staging, production, or publish target
      • Syntax highlighting with 11 code syntax choices
      • Theme choice

    Edit Asset
  5. After configuring the items click Create
  6. Once the asset has been created, Publish the asset

Like pages, created and saved assets can be immediately published, scheduled to publish, or sent to user for approval. An unpublished asset can even be inserted onto pages; however, an asset does not render on the production server until it has been published.