# Nascondi determinate impostazioni di gruppo se il nome del gruppo include un nome specifico

**URL:** <https://meta.discourse.org/t/hide-certain-group-settings-if-group-name-includes-a-specific-name/237917>\
**Category:** Development\
**Created:** [2 Settembre 2022, 8:25am UTC](https://meta.discourse.org/t/hide-certain-group-settings-if-group-name-includes-a-specific-name/237917 "2022-09-02T08:25:48Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![AquaL1te](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/aqual1te/32/201966_2.png) [@AquaL1te](https://meta.discourse.org/u/AquaL1te)\
**Post date:** [8 Settembre 2022, 2:59pm UTC](https://meta.discourse.org/t/hide-certain-group-settings-if-group-name-includes-a-specific-name/237917/4 "2022-09-08T14:59:35Z")

</div>

Capisco e accetto che devo creare queste funzioni da solo, non è come Jinja2 con utili cose integrate per farlo.

Ma dove creo queste funzioni handlebars nel mio plugin? Vedo parecchi esempi qui: [Repository search results · GitHub](https://github.com/discourse/discourse/search?q=handlebars)

Ma non vedo davvero uno schema in questa struttura di cartelle. Ho creato la mia funzione in `discourse-group-custom-fields/assets/javascripts/discourse/app/helpers/contains.js`, ma quando provo a usarla in `discourse-group-custom-fields/assets/javascripts/discourse/connectors/group-edit/field-container.hbs` ottengo l’errore `Uncaught Error: Attempted to resolve "contains", which was expected to be a component, but nothing was found.`. Quindi, ovviamente, questo non è un percorso in cui Discourse sta cercando, o sto facendo qualcosa di sbagliato.

```js
import RawHandlebars from "discourse-common/lib/raw-handlebars";
import { htmlSafe } from "@ember/template";
import { rawConnectorsFor } from "discourse/lib/plugin-connectors";

//RawHandlebars.registerHelper("contains", function (args) {
// const connectors = rawConnectorsFor(args.hash.name);
// if (connectors.length) {
// const output = connectors.map((c) => c.template({ context: this }));
// return htmlSafe(output.join(""));
// }
//});

Handlebars.registerHelper('contains', function(needle, haystack, options) {
     needle = Handlebars.escapeExpression(needle);
     haystack = Handlebars.escapeExpression(haystack);
     return (haystack.indexOf(needle) > -1) ? options.fn(this) : options.inverse(this);
});

```

L’argomento sottostante suggerisce che potrebbe trovarsi nella directory degli initializers e avere l’estensione .es6.

> **[A not so simple Discourse Plugin - Handlebars.registerHelper](https://www.sitepoint.com/community/t/a-not-so-simple-discourse-plugin-handlebars-registerhelper/169496)**
>
> Inspired from this discussion https://meta.discourse.org/t/adding-share-buttons-to-every-post-image/27590 I decided to look into what would be involved with creating such a plugin. Expanding on what I’ve learned previously, That is, plugin.rb...

Quindi ho spostato il mio contains.js in quella directory e ho aggiunto .es6 come estensione e ho ottenuto lo stesso errore. Qualsiasi aiuto o documentazione sarebbe molto apprezzato 🙂

---

_[View the full topic](https://meta.discourse.org/t/hide-certain-group-settings-if-group-name-includes-a-specific-name/237917)._
