## Skin

    Object
       |
       +--Skin

SUMMARY: Constructor | Properties | Methods | DETAIL: Constructor | Properties | Methods

Methods Summary
`void` | `allowMacro(<String> macroname)` Limits the range of allowed macros to be rendered in a skin to an explicit set.
`Boolean` | `containsMacro(<String> macroname)` Checks whether a skin does contain a specific macro.
`String` | `getSource()` Returns the source of the unrendered skin.
`Skin` | `getSubskin(<String> name)` Returns a subskin by that name.
`Array` | `getSubskinNames()` Returns an array of names of all the subskins defined in this skin.
`Boolean` | `hasMainskin()` Checks if this skin has a main skin, as opposed to consisting just of subskins.
`Boolean` | `hasSubskin(<String> name)` Check if this skin contains a subskin with the given name.

Method Detail

### allowMacro

    void allowMacro(<String> macroname)

Limits the range of allowed macros to be rendered in a skin to an explicit set.
This is useful e.g. when text entered by non-trusted users is interpreted as skins to provide macro functions on a user-level.
Example:

     // Two macro functions defined in a JavaScript file:

    function isAllowed_macro() {
       return("Hello");
     }

    function isForbidden_macro() {
       return("World");
     }

     // The action that enables one of the macros:

    function test_action() {
       var str = "<% root.isAllowed %>, <% root.isForbidden %>!";
       var skin = createSkin(str);
       // as soon as we call allowMacro() on a skin, only those
       // macros explicitely set are allowed to be evaluated.
       // all others will result in an error msg.
       skin.allowMacro("root.isAllowed");
       renderSkin(skin);
     }

     Hello, [Macro root.isForbidden not allowed in sandbox]!

Parameters:

`macroname` - as String

### containsMacro

    Boolean containsMacro(<String> macroname)

Checks whether a skin does contain a specific macro.
This is useful to make sure a user-edited skin does not contain any macro with which the application would break.

Example:

     var skin1 = createSkin("myMacro");
     var skin2 = createSkin("<% myMacro %>");
     var skin3 = createSkin("<% this.myMacro %>");

     res.writeln(skin1.containsMacro("myMacro"));
     false

     res.writeln(skin2.containsMacro("myMacro"));
     true

     res.writeln(skin3.containsMacro("myMacro"));
     false

     res.writeln(skin3.containsMacro("this.myMacro"));
     true

Parameters:

`macroname` - as String

Returns:

Boolean true if the skin contains the specified macro, otherwise false

### getSource

    String getSource()

Returns the source of the unrendered skin.

Returns:

String with the source of the unrendered skin

### getSubskin

    Skin getSubskin(<String> name)

Returns a subskin by that name.

Parameters:

`name` - as String, the subskin name

Returns:

Skin the subskin

### getSubskinNames

    Array getSubskinNames()

Returns an array of names of all the subskins defined in this skin.

Returns:

Array of Strings containing this skin's subskin names

### hasMainskin

    Boolean hasMainskin()

Checks if this skin has a main skin, as opposed to consisting just of subskins.

Returns:

Boolean true if this skin contains a main skin

### hasSubskin

    Boolean hasSubskin(<String> name)

Check if this skin contains a subskin with the given name.

Parameters:

`name` - as String, a subskin name

Returns:

Boolean true if the given subskin exists

SUMMARY: Constructor | Properties | Methods | DETAIL: Constructor | Properties | Methods

Documentation generated by JSDoc on Thu Apr 5 01:59:00 2007