Explore the introductions below and discover what you
can do with Helma and Javascript on the server-side.

introductions

macros

Macros are methods of application logic that can be called through custom macro tags contained in skins. Macros allow skins to pull data from application logic, while other macro tags only push pre-determined data to the skins.

You will find an example for such a skin in the "welcome" application at ./apps/welcome/code/Root/example_using_macro.skin

<p>This is an example of a skin calling a macro.</p>
<p>You will find this skin at 
    ./apps/welcome/code/Root/example_using_macro.skin</p>
<p>This skin is rendered by the action defined at 
    ./apps/welcome/code/Root/example_using_macro.hac</p>
<p>The macro this skin calls is defined in 
    ./apps/welcome/code/Root/example.js</p>
<p>You can test it via the URL 
    <a href="<% this.pullLink part="url" %>">
        <% this.pullLink part="text" %>
    </a>
</p>

In this example, the skin calls a "pullLink" macro twice, using a different "part" parameter. Macro methods are defined using a corresponding function name with a "_macro" suffix. The pullLink macro used in this example, you will find defined in ./apps/welcome/code/Root/example.js

function pullLink_macro(params) {
    switch (params.part) {
        case 'text' : 
            return '/example_using_macro';
        case 'url'  : 
            return this.href('example_using_macro');;
    }
}

You can test this macro and see the skin rendered via the URL http://serverjs.org/example_using_macro

Note that macros can again make use of skins, which may again contain macro calls. This combination of skins and macros allows actions to delegate the response generation through multiple tiers of "control" and "presentation".

More information about macro tags and ways in which you can use custom defined macros:
/docs/Request-Response-Cycle/