Child pages
  • Vise kildekoden
Skip to end of metadata
Go to start of metadata

Makroen 'code' er nyttig for å presentere kildkode på et vellformatert og lesbart format i Confluence sider. Bruken er veldig rett fram: sett kildekoden din i mellom {code} elementer.

Her er noen eksempler.

XML

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

gir

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

SQL

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

gir

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}

gir

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;
    }
}

For mer informasjon, se dokumentasjonen.

  • No labels