Dashboard > Demonstration Space > Confluence Overview 2- temp edit > Source code
Source code Log In | Sign Up   View a printable version of the current page.

Added by Anonymous , last edited by Anonymous on Dec 17, 2005  (view change)
Labels: 
(None)

For other macros, besides that of the source code macro discussed below, please visit The Guide to Confluence Macros.

The source code macro is a useful way of presenting technical information to a group of users online. It's use is very straightforward. Any form of code can be included between {code} elements and we provide arguments for XML, SQL, and Java.

As you read below, look for the bolded code tags to indicate how the highlighting occurs.

XML

\{code:XML\}
<test>
    <another tag="attribute"/>
</test>
\{code\}

gives

<test>
    <another tag="attribute"/>
</test>

SQL

\{code:SQL\}
SELECT * FROM TABLE1 WHERE ID=0 AND NAME NOT IN (SELECT NAME FROM NAMES)
\{code\}
SELECT * FROM TABLE1 WHERE ID=0 AND NAME NOT IN (SELECT NAME FROM NAMES)

Java

\{code:Java\}
package com.atlassian.confluence.admin.actions.macros;

import com.atlassian.confluence.renderer.UserMacroLibrary;

public class UserMacroBean
{
    String name;
    String template;

    public UserMacroBean()
    {
    }

    public UserMacroBean(String name, UserMacroLibrary userMacroLibrary)
    {
        this.name = name;
        this.template = userMacroLibrary.getMacroTemplate(name);
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public String getTemplate()
    {
        return template;
    }

    public void setTemplate(String template)
    {
        this.template = template;
    }
}
\{code\}

gives

package com.atlassian.confluence.admin.actions.macros;

import com.atlassian.confluence.renderer.UserMacroLibrary;

public class UserMacroBean
{
    String name;
    String template;

    public UserMacroBean()
    {
    }

    public UserMacroBean(String name, UserMacroLibrary userMacroLibrary)
    {
        this.name = name;
        this.template = userMacroLibrary.getMacroTemplate(name);
    }

    public String getName()
    {
        return name;
    }

    public void setName(String name)
    {
        this.name = name;
    }

    public String getTemplate()
    {
        return template;
    }

    public void setTemplate(String template)
    {
        this.template = template;
    }
}
Powered by a free Atlassian Confluence Open Source Project License granted to FarCry CMS. Evaluate Confluence today.
Powered by Atlassian Confluence 2.7, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators