2015-02-11 32 views
0

我是Confluence插件開發的新手。我想使用API​​中的示例。比如看這個頁面,有HTML-Code和JS-Code分開。Confluence插件在哪裏定義HTML代碼

我知道如何定義一個JS文件以及如何參考atlassian-plugin.xml

看看這裏

<web-resource key="Confluence-resources" name="Confluence-Web-Resources"> 
    <dependency>com.atlassian.auiplugin:ajs</dependency> 
    <resource type="download" name="confluence.js" location="/js/confluence.js"/> 

    </web-resource> 

但在這裏我必須定義的HTML代碼?

回答

2

本質上,您需要在Macro類中呈現execute方法中的HTML。但實際上,有一些「Atlassian認可的」方法。

您可能想要考慮從VelocityUtils.getRenderedTemplate方法中的內置速度模板支持。

引用Atlassian's Documentation,你也許可以寫類似:

public String execute(Map params, String body, RenderContext renderContext) throws MacroException { 
    // do something with params ... 

    Map context = MacroUtils.defaultVelocityContext(); 
    context.put("page", page); 
    context.put("labels", labels); 
    return VelocityUtils.getRenderedTemplate("com/atlassian/confluence/example/sample-velocity.vm", context); 
} 

近年來,他們開始推廣使用Soy Template了。

相關問題