Server-side JavaScript

Welcome

Login to contribute. Register if you haven't yet.

Support Options

1. Search this site.
2. Make or vote for a Suggestion.
3. Post to Community Support.
3. Contact EditMe Support staff.

Stay Informed

Keep informed of product changes, tutorials and tips via EditMe's Blog and monthly newsletter.

Server Side Script Tags

Server side script tags are special <script> tags that execute EditMe JavaScript code on the server. These scripts can modify the output of the page via its Layout. Script tags can be used in conjunction with layout commands to provide space for declaration of functions, classes and other code.

Server side script tags are parsed out of the layout for processing and removed from the content returned to the browser. 

Because layout and script pages must be valid XML, the contents of script tags should be enclosed in a CDATA section. This allows the JavaScript code to break certain XML validation rules.

At this time, server side script tags do not support the SRC attribute for referencing external scripts. SRC attributes will simply be ignored. A future release will likely add support for linked scripts using the SRC attribute.

There are three types of server side script tags. The script type is defined by the value of the TYPE attribute on the script tag itself. The following values are supported:

  • text/vnd.editme.js.pre - Pre-press script
  • text/vnd.editme.js - Inline script
  • text/vnd.editme.js.post - Post-press script

Pre-Press Scripts

Probably the most common, a pre-press script runs before EditMe processes the layout commands for a page request, regardless of the placement of the script tag. For readability, pre-press script tags should be placed in the HEAD tag of the layout. Pre-press scripts should contain any JavaScript functions for variable declarations used in your layout commands.

Example:

<script type="text/vnd.editme.js.pre"><![CDATA[
    // script goes here 
]]></script>

Inline Scripts

Inline scripts are processed in the order that they appear in the layout XML. Layout commads that appear before an inline script will have been processed before the inline script is processed. Likewise, an inline script will be processed before any layout commands that follow it. Inline scripts are what should be used to house code in scripted pages.

Example:

<p editme="text 'runs before the inline script'"></p>
<script type="text/vnd.editme.js"><![CDATA[
    // script goes here 
]]></script>
<p editme="text 'runs after the inline script'"></p>

Post-press Scripts

Post-press scripts run after EditMe has processed all layout commands, regardless of the placement of the script tag. 

Example:

<script type="text/vnd.editme.js.post"><![CDATA[
    // script goes here 
]]></script>