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 Java Script Includes

Back to Developer Support

As you begin to write  write an application in EditMe, you'll quickly realize you need to reuse code between multiple pages. It is good programming style to modularize programs and keep reused code in modules that can be applied when needed. EditMe provides this capability.

While there is not way to evaluate code directly within EditMe's JavaScript implementation, you can execute code in other pages by using the process attribute command.

For example, here is a EditMe Scripted Page that contains two functions for reuse across multiple pages:

Page: SharedFunctions

<script type="text/vnd.editme.js">
function addNumbers(n1, n2) {
    return n1+n2;
}
function subtractNumbers(n1, n2) {
    return n1-n2;
}
</script> 

 And here is a page that reuses the code:

Page: MyPage

<div>
    <span editme="process 'SharedFunctions'" />
    <script type="text/vnd.editme.js">
        var result1 = addNumbers(2, 1);
        var result2 = subtractNumbers(2, 1);
    </script>
    <p editme="parse">2+1={result1}.</p> 
    <p editme="parse">2-1={result2}.</p> 
</div>