mirror of
https://github.com/discourse/discourse.git
synced 2025-02-27 16:06:10 +00:00
DEV: add replaceTagRenderer to pluginApi
This commit is contained in:
parent
18296b4211
commit
4955ab1689
@ -31,6 +31,7 @@ import {
|
|||||||
replaceIcon
|
replaceIcon
|
||||||
} from "discourse-common/lib/icon-library";
|
} from "discourse-common/lib/icon-library";
|
||||||
import { replaceCategoryLinkRenderer } from "discourse/helpers/category-link";
|
import { replaceCategoryLinkRenderer } from "discourse/helpers/category-link";
|
||||||
|
import { replaceTagRenderer } from "discourse/lib/render-tag";
|
||||||
import { addNavItem } from "discourse/models/nav-item";
|
import { addNavItem } from "discourse/models/nav-item";
|
||||||
import { replaceFormatter } from "discourse/lib/utilities";
|
import { replaceFormatter } from "discourse/lib/utilities";
|
||||||
import { modifySelectKit } from "select-kit/mixins/plugin-api";
|
import { modifySelectKit } from "select-kit/mixins/plugin-api";
|
||||||
@ -42,7 +43,7 @@ import Sharing from "discourse/lib/sharing";
|
|||||||
import { addComposerUploadHandler } from "discourse/components/composer-editor";
|
import { addComposerUploadHandler } from "discourse/components/composer-editor";
|
||||||
|
|
||||||
// If you add any methods to the API ensure you bump up this number
|
// If you add any methods to the API ensure you bump up this number
|
||||||
const PLUGIN_API_VERSION = "0.8.28";
|
const PLUGIN_API_VERSION = "0.8.29";
|
||||||
|
|
||||||
class PluginApi {
|
class PluginApi {
|
||||||
constructor(version, container) {
|
constructor(version, container) {
|
||||||
@ -830,6 +831,21 @@ class PluginApi {
|
|||||||
replaceCategoryLinkRenderer(fn);
|
replaceCategoryLinkRenderer(fn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a renderer that overrides the display of a tag.
|
||||||
|
*
|
||||||
|
* Example:
|
||||||
|
*
|
||||||
|
* function testTagRenderer(tag, params) {
|
||||||
|
* const visibleName = Handlebars.Utils.escapeExpression(tag);
|
||||||
|
* return `testing: ${visibleName}`;
|
||||||
|
* }
|
||||||
|
* api.replaceTagRenderer(testTagRenderer);
|
||||||
|
**/
|
||||||
|
replaceTagRenderer(fn) {
|
||||||
|
replaceTagRenderer(fn);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers custom languages for use with HighlightJS.
|
* Registers custom languages for use with HighlightJS.
|
||||||
*
|
*
|
||||||
|
@ -1,4 +1,10 @@
|
|||||||
export default function renderTag(tag, params) {
|
let _renderer = defaultRenderTag;
|
||||||
|
|
||||||
|
export function replaceTagRenderer(fn) {
|
||||||
|
_renderer = fn;
|
||||||
|
}
|
||||||
|
|
||||||
|
function defaultRenderTag(tag, params) {
|
||||||
params = params || {};
|
params = params || {};
|
||||||
const visibleName = Handlebars.Utils.escapeExpression(tag);
|
const visibleName = Handlebars.Utils.escapeExpression(tag);
|
||||||
tag = visibleName.toLowerCase();
|
tag = visibleName.toLowerCase();
|
||||||
@ -41,3 +47,7 @@ export default function renderTag(tag, params) {
|
|||||||
|
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default function renderTag(tag, params) {
|
||||||
|
return _renderer(tag, params);
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user