【问题标题】:Access Java values in a custom widget, from erb template in Sonar从 Sonar 中的 erb 模板访问自定义小部件中的 Java 值
【发布时间】:2023-03-21 23:08:02
【问题描述】:

是否可以使用声纳 api 从 erb 模板访问自定义 Widget 类中声明的 Java 值。

提前感谢您的帮助。

【问题讨论】:

    标签: plugins sonarqube


    【解决方案1】:

    当您说 Java 值时,您是指小部件实例的属性吗?如果是这样,那是不可能的。

    但是,有@WidgetProperties 和@WidgetProperty 注释(参见[1])允许您定义用户可以自定义的小部件属性(如果需要,可以使用默认值)。在您的 Ruby 模板中,您将能够使用语法“widget_properties['the_property_name']”来访问它们(参见 [2])。

    [1]https://github.com/SonarSource/sonar/blob/master/plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/widgets/TimelineWidget.java

    [2]https://github.com/SonarSource/sonar/blob/master/plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/timeline.html.erb

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多