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>